File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change 1+ const { Workspace } = require ( '../index.js' ) ;
2+ const Soup = require ( '@stews/soup' ) ;
3+ const fs = require ( 'fs' ) ;
4+
5+
6+ Workspace . newF ( "__buildScripts" , function ( ) { // function for building the workspace.script property
7+
8+ // a list of the script's raw code excluding meta files bc those will be used later
9+ let scriptFiles = fs . readdirSync ( this . scriptsDir ) . filter ( file => ! file . endsWith ( ".meta" ) ) ;
10+
11+
12+ scriptFiles . forEach ( file => {
13+ let name = file . replace ( ".unity" , "" ) ; // name of the script
14+ const script = new this . Script ( name ) ; // creates a new script typing
15+
16+ let data = fs . readFileSync ( `${ this . scriptDir } /${ file } ` , 'utf8' ) ; // script data
17+ let meta = fs . readFileSync ( `${ this . scriptDir } /${ file } .meta` , 'utf8' ) ; // script metadata
18+
19+ script . translate ( data , meta ) ; // translates the scripts's metadata and data into usable JSON data
20+ this . scripts . push ( name , script ) ; // pushes the new script into the script group
21+ } ) ;
22+ } ) ;
You can’t perform that action at this time.
0 commit comments