Пример #1
0
        private void OnSelectedScript(JSScriptClassPathHint classPath)
        {
            if (_enabled && _target != null && !classPath.IsReferenced(_target.scriptRef))
            {
                var scriptRef = _target.scriptRef;

                scriptRef.sourceFile = classPath.sourceFile;
                if (scriptRef.modulePath != classPath.modulePath || scriptRef.className != classPath.className)
                {
                    scriptRef.modulePath = classPath.modulePath;
                    scriptRef.className  = classPath.className;

                    _target.scriptRef = scriptRef;
                    this.ReleaseJSValues();
                    _target.ReleaseScriptInstance();
                    _target.CreateScriptInstance();

                    // 重新绑定当前编辑器脚本实例
                    this.CreateScriptInstance();
                    EditorUtility.SetDirty(_target);
                }
                else
                {
                    _target.scriptRef = scriptRef;
                }

                EditorUtility.SetDirty(_target);
            }
        }
Пример #2
0
 private void OnConfirmSearchResult(JSScriptClassPathHint result)
 {
     try
     {
         _selectCallback?.Invoke(result);
     }
     catch (Exception exception)
     {
         Debug.LogError(exception);
     }
     Close();
     GUIUtility.ExitGUI();
     Event.current.Use();
 }
Пример #3
0
        private void ParseFile(string filePath)
        {
            if (!filePath.EndsWith(".ts"))
            {
                return;
            }

            string modulePath;

            string[] classNames;
            if (UnityHelper.ResolveScriptRef(_baseDir, filePath, out modulePath, out classNames))
            {
                foreach (var className in classNames)
                {
                    var hint = new JSScriptClassPathHint(filePath, modulePath, className);
                    _scriptClassPaths.Add(hint.ToClassPath(), hint);
                }
            }
        }