Example #1
0
        void Awake()
        {
            _rt = ScriptEngine.CreateRuntime();
            var fileSystem = new DefaultFileSystem();

            _rt.AddSearchPath("Assets");
            _rt.AddSearchPath("node_modules");
            _rt.EnableStacktrace();
            if (sourceMap)
            {
                _rt.EnableSourceMap();
            }
            _rt.Initialize(fileSystem, this, new UnityLogger(), new ByteBufferPooledAllocator());
        }
Example #2
0
        private void OnScriptRuntimeInitialized(ScriptRuntime runtime)
        {
            var tsconfig = GetTSConfig();

            if (tsconfig != null)
            {
                runtime.AddSearchPath(tsconfig.compilerOptions.outDir);
            }

            runtime.EvalMain(_prefs.editorEntryPoint);

            foreach (var module in _prefs.editorRequires)
            {
                runtime.ResolveModule(module);
            }

            var editorScripts = new List <JSScriptClassPathHint>();

            JSScriptFinder.GetInstance().ModuleSourceChanged += OnModuleSourceChanged;
            JSScriptFinder.GetInstance().Search(JSScriptClassType.Editor, editorScripts);
            foreach (var editorScript in editorScripts)
            {
                runtime.ResolveModule(editorScript.modulePath);
            }
        }
Example #3
0
 public void OnCreate(ScriptRuntime runtime)
 {
     runtime.AddSearchPath("Scripts/out");
     runtime.AddSearchPath("node_modules");
 }