Пример #1
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);
            }
        }
Пример #2
0
        private void Init(Rect rect)
        {
            var screenRect = GUIUtility.GUIToScreenRect(rect);

            ShowAsDropDown(screenRect, CalculateWindowSize(rect));

            _searchResults.Clear();
            JSScriptFinder.GetInstance().Search(_searchString, _searchType, _searchResults);
        }
Пример #3
0
        private JSScriptFinder GetScriptFinder()
        {
            if (_finder == null)
            {
                var baseDir = UnityHelper.LoadPrefs().sourceDir;
                _finder = new JSScriptFinder(baseDir);

                //TODO: need optimization, make the full collecting process async, and wait it finished
                _finder.Start();
            }

            return(_finder);
        }
Пример #4
0
        public static JSScriptFinder GetInstance()
        {
            if (_finder == null)
            {
                var prefs   = UnityHelper.LoadPrefs();
                var baseDir = prefs.sourceDir;

                _finder = new JSScriptFinder(baseDir, prefs.typescriptExt);
                _finder.Start(); //TODO: need optimization, make the full collecting process async, and wait it finished
            }

            return(_finder);
        }
Пример #5
0
        private void OnQuitting()
        {
            if (_runtime == null)
            {
                return;
            }
            var runtime = _runtime;

            _runtime = null;
            _runMode = RunMode.None;
            JSScriptFinder.GetInstance().ModuleSourceChanged -= OnModuleSourceChanged;
            EditorApplication.delayCall            -= OnInit;
            EditorApplication.update               -= OnUpdate;
            EditorApplication.quitting             -= OnQuitting;
            EditorApplication.playModeStateChanged -= OnPlayModeStateChanged;
            runtime.Shutdown();
        }
Пример #6
0
        private void DrawSearchField()
        {
            var rect = GUILayoutUtility.GetRect(1, 1, 18, 18, GUILayout.ExpandWidth(true));

            if (_searchField == null)
            {
                _searchField = new SearchField();
                _searchField.downOrUpArrowKeyPressed += OnDownOrUpArrowKeyPressed;
            }

            var result = _searchField.OnGUI(rect, _searchString);

            if (result != _searchString)
            {
                _searchString = result;
                _searchResults.Clear();
                JSScriptFinder.GetInstance().Search(_searchString, _searchType, _searchResults);
            }

            rect.y += 18;
            DrawSearchResults(rect);
        }