-
Notifications
You must be signed in to change notification settings - Fork 713
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Have Unity auto import .cjs files as TextAssets. These files are reco…
…gnized by IDEs as JavaScript files (for syntax highlighting and debugging), and can be used directly with NodeJS.
- Loading branch information
1 parent
98f7c7a
commit ff24112
Showing
3 changed files
with
27 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System.IO; | ||
using UnityEditor.Experimental.AssetImporters; | ||
using UnityEngine; | ||
|
||
[ScriptedImporter(1, "cjs")] | ||
public class CJSImporter : ScriptedImporter | ||
{ | ||
public override void OnImportAsset(AssetImportContext ctx) | ||
{ | ||
TextAsset subAsset = new TextAsset( File.ReadAllText( ctx.assetPath ) ); | ||
ctx.AddObjectToAsset("text", subAsset); | ||
ctx.SetMainObject( subAsset ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters