Esempio n. 1
0
        public static void OpenFile(string path)
        {
            string filePath = Path.GetFullPath(path);

            if (!File.Exists(filePath))
            {
                Debug.LogError(string.Format("Path {0} doesn't exists", path));
                return;
            }

            string externalScriptEditor = ScriptEditorUtility.GetExternalScriptEditor();

            if (externalScriptEditor != "internal")
            {
                ProcessStartInfo psi = CreateProcessStartInfo(filePath);
                Process.Start(psi);
            }
            else
            {
                Process p = new Process();
                p.StartInfo.FileName  = filePath;
                p.EnableRaisingEvents = true;
                p.Exited += (Object obj, EventArgs args) =>
                {
                    if (p.ExitCode != 0)
                    {
                        Debug.LogWarningFormat("Unable to open {0}: Check external editor in preferences", filePath);
                    }
                };
                p.Start();
            }
        }
        private static void OpenVisualStudioFile(string projectPath, string file, int line)
        {
#if UNITY_2017_1_OR_NEWER
            string vsPath = ScriptEditorUtility.GetExternalScriptEditor();
#else
            string vsPath = InternalEditorUtility.GetExternalScriptEditor();
#endif
            if (IsNotWindowsEditor())
            {
                Process.Start("open", "-a " + QuotePathIfNeeded(vsPath) + " " + QuotePathIfNeeded(file));
                return;
            }

            if (string.IsNullOrEmpty(vsPath) || !File.Exists(vsPath))
            {
                return;
            }
            string exePath = String.Empty;

#if UNITY_2018_1_OR_NEWER
            var packageInfos = Packages.GetAll();
            foreach (var packageInfo in packageInfos)
            {
                if (packageInfo.name == "com.wuhuan.consoletiny")
                {
                    exePath = packageInfo.resolvedPath;
                    // https://github.com/akof1314/VisualStudioFileOpenTool
                    exePath = exePath + "\\Editor\\VisualStudioFileOpenTool.exe";
                    break;
                }
            }
#elif UNITY_2017_1_OR_NEWER
            // TODO
            exePath = "../../PackagesCustom/com.wuhuan.consoletiny";
#endif
            if (string.IsNullOrEmpty(exePath))
            {
                exePath = "Assets/Editor/VisualStudioFileOpenTool.exe";
            }

            if (!string.IsNullOrEmpty(exePath))
            {
                if (!File.Exists(exePath))
                {
                    return;
                }

                ThreadPool.QueueUserWorkItem(_ =>
                {
                    OpenVisualStudioFileInter(exePath, vsPath, projectPath, file, line);
                });
            }
        }
Esempio n. 3
0
        public static void Initialize(string editorPath)
        {
            string externalEditor = editorPath ?? ScriptEditorUtility.GetExternalScriptEditor();

            if (Application.platform == RuntimePlatform.OSXEditor)
            {
                UnityVSSupport.InitializeVSForMac(externalEditor);
            }
            else if (Application.platform == RuntimePlatform.WindowsEditor)
            {
                UnityVSSupport.InitializeVisualStudio(externalEditor);
            }
        }
Esempio n. 4
0
        public void OpenEditor(string projectPath, string file, int line)
        {
            m_SolutionFile = projectPath;

            if (m_ScriptOpenerType != null)
            {
                ThreadPool.QueueUserWorkItem(_ =>
                {
                    OpenEditorInter(projectPath, file, line);
                });
            }
            else
            {
#if UNITY_2017_1_OR_NEWER
                string vsPath = ScriptEditorUtility.GetExternalScriptEditor();
#else
                string vsPath = InternalEditorUtility.GetExternalScriptEditor();
#endif
                if (string.IsNullOrEmpty(vsPath) || !File.Exists(vsPath))
                {
                    return;
                }
                string exePath = String.Empty;

#if UNITY_2018_1_OR_NEWER
                var packageInfos = Packages.GetAll();
                foreach (var packageInfo in packageInfos)
                {
                    if (packageInfo.name == "com.wuhuan.consoletiny")
                    {
                        exePath = packageInfo.resolvedPath;
                        break;
                    }
                }
#elif UNITY_2017_1_OR_NEWER
                // TODO
                exePath = "../../PackagesCustom/com.wuhuan.consoletiny";
#endif

                if (!string.IsNullOrEmpty(exePath))
                {
                    exePath = exePath + "\\Editor\\VisualStudioFileOpenTool.exe";

                    ThreadPool.QueueUserWorkItem(_ =>
                    {
                        OpenEditorInter2(exePath, vsPath, projectPath, file, line);
                    });
                }
            }
        }
        public void OnGUI()
        {
            List <IDEToolLib.IDEInfo> dic = IDEToolLib.Instance.SettingInfoList;

            IDEToolLib.IDEInfo version = IDEToolLib.Instance.TryGetIDEInfo(IDEToolLib.VersionKey);
            GUILayout.Label("CfgVer: " + version.Path);
            _scrollPos = EditorGUILayout.BeginScrollView(_scrollPos);

            foreach (IDEToolLib.IDEInfo pair in dic)
            {
                if (pair.Name != IDEToolLib.VersionKey)
                {
                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.BeginHorizontal();
                    string tempName = GUILayout.TextField(pair.Name, new GUILayoutOption[] { GUILayout.Width(150) });
                    string tempPath = GUILayout.TextField(pair.Path, new GUILayoutOption[] { GUILayout.Width(400) });
                    if (EditorGUI.EndChangeCheck())
                    {
                        pair.Name = tempName;
                        pair.Path = tempPath;
                    }

                    if (GUILayout.Button("SelectEXE"))
                    {
                        string path = EditorUtility.OpenFilePanel("ChooseExe", "", "exe");
                        if (!string.IsNullOrEmpty(path))
                        {
                            pair.Path = path;
                        }
                    }

                    EditorGUI.BeginDisabledGroup(ScriptEditorUtility.GetExternalScriptEditor() == pair.Path);
                    if (GUILayout.Button("USE"))
                    {
                        ScriptEditorUtility.SetExternalScriptEditor(pair.Path);
                    }

                    EditorGUI.EndDisabledGroup();
                    EditorGUILayout.EndHorizontal();
                }
            }

            if (GUILayout.Button("Add New IDE"))
            {
                IDEToolLib.IDEInfo newInfo = new IDEToolLib.IDEInfo("NewIDE", "");
                dic.Add(newInfo);
            }

            EditorGUILayout.EndScrollView();
        }
Esempio n. 6
0
        public static void Initialize(string editorPath)
        {
            var externalEditor = editorPath ?? ScriptEditorUtility.GetExternalScriptEditor();

            if (Application.platform == RuntimePlatform.OSXEditor)
            {
                InitializeVSForMac(externalEditor);
                return;
            }

            if (Application.platform == RuntimePlatform.WindowsEditor)
            {
                InitializeVisualStudio(externalEditor);
            }
        }
        public static void OpenFile(string path)
        {
            if (!File.Exists(Path.GetFullPath(path)))
            {
                Debug.LogError(string.Format("Path {0} doesn't exists", path));
                return;
            }

            string           file = Path.GetFullPath(path);
            ProcessStartInfo pi   = new ProcessStartInfo(file);

            pi.Arguments        = Path.GetFileName(file);
            pi.UseShellExecute  = true;
            pi.WorkingDirectory = Path.GetDirectoryName(file);
            pi.FileName         = ScriptEditorUtility.GetExternalScriptEditor();
            pi.Verb             = "OPEN";
            Process.Start(pi);
        }
Esempio n. 8
0
        static ProcessStartInfo CreateProcessStartInfo(string filePath)
        {
            string externalScriptEditor = ScriptEditorUtility.GetExternalScriptEditor();

            ProcessStartInfo psi = new ProcessStartInfo();

            psi.UseShellExecute = false;


        #if UNITY_EDITOR_OSX
            string arg = string.Format("-a \"{0}\" -n --args \"{1}\"", externalScriptEditor, Path.GetFullPath(filePath));
            psi.FileName  = "open";
            psi.Arguments = arg;
        #else
            psi.Arguments        = Path.GetFileName(filePath);
            psi.WorkingDirectory = Path.GetDirectoryName(filePath);
            psi.FileName         = externalScriptEditor;
        #endif
            return(psi);
        }
Esempio n. 9
0
        static void GenerateSolution()
        {
            using (var progress = new BuildProgress(k_Title, "Please wait..."))
            {
                var result = BeeTools.Run("ProjectFiles", new DotsRuntimeBuildProfile().BeeRootDirectory, progress);
                if (!result.Succeeded)
                {
                    UnityEngine.Debug.LogError($"{k_Title} failed.\n{result.Error}");
                    return;
                }

                var scriptEditor = ScriptEditorUtility.GetExternalScriptEditor();
                var projectPath  = new NPath(UnityEngine.Application.dataPath).Parent;
                var pi           = new ProcessStartInfo();
                pi.FileName  = scriptEditor;
                pi.Arguments = $"{projectPath.Combine(projectPath.FileName + "-Dots.sln").InQuotes()}";
                var proc = new Process();
                proc.StartInfo = pi;
                proc.Start();
            }
        }
Esempio n. 10
0
        static void OpenSolution()
        {
            var scriptEditor = new NPath(ScriptEditorUtility.GetExternalScriptEditor());
            var sln          = GetSolutionPath().InQuotes();

#if UNITY_EDITOR_OSX
            var pi = new ProcessStartInfo
            {
                FileName        = "/usr/bin/open",
                Arguments       = $"-a {scriptEditor.InQuotes()} {sln}",
                UseShellExecute = false
            };
#else
            var pi = new ProcessStartInfo
            {
                FileName  = scriptEditor.ToString(),
                Arguments = sln,
            };
#endif
            var proc = new Process {
                StartInfo = pi
            };
            proc.Start();
        }
Esempio n. 11
0
        private void ReadPreferences()
        {
            m_ScriptEditorPath.str = ScriptEditorUtility.GetExternalScriptEditor();
            m_ScriptEditorArgs     = ScriptEditorUtility.GetExternalScriptEditorArgs();

            m_ExternalEditorSupportsUnityProj = EditorPrefs.GetBool("kExternalEditorSupportsUnityProj", false);
            m_ImageAppPath.str = EditorPrefs.GetString("kImagesDefaultApp");

            m_ScriptApps         = BuildAppPathList(m_ScriptEditorPath, kRecentScriptAppsKey, "internal");
            m_ScriptAppsEditions = new string[m_ScriptApps.Length];

            if (Application.platform == RuntimePlatform.WindowsEditor)
            {
                foreach (var vsPaths in SyncVS.InstalledVisualStudios.Values)
                {
                    foreach (var vsPath in vsPaths)
                    {
                        int index = Array.IndexOf(m_ScriptApps, vsPath.Path);
                        if (index == -1)
                        {
                            ArrayUtility.Add(ref m_ScriptApps, vsPath.Path);
                            ArrayUtility.Add(ref m_ScriptAppsEditions, vsPath.Edition);
                        }
                        else
                        {
                            m_ScriptAppsEditions[index] = vsPath.Edition;
                        }
                    }
                }
            }

            var foundScriptEditorPaths = ScriptEditorUtility.GetFoundScriptEditorPaths(Application.platform);

            foreach (var scriptEditorPath in foundScriptEditorPaths.Keys)
            {
                ArrayUtility.Add(ref m_ScriptApps, scriptEditorPath);
                ArrayUtility.Add(ref m_ScriptAppsEditions, null);
            }

            m_ImageApps = BuildAppPathList(m_ImageAppPath, kRecentImageAppsKey, "");

            m_ScriptAppDisplayNames = BuildFriendlyAppNameList(m_ScriptApps, m_ScriptAppsEditions, foundScriptEditorPaths,
                                                               "Open by file extension");

            m_ImageAppDisplayNames = BuildFriendlyAppNameList(m_ImageApps, null, null,
                                                              L10n.Tr("Open by file extension"));

            m_DiffTools = InternalEditorUtility.GetAvailableDiffTools();

            // only show warning if has team license
            if ((m_DiffTools == null || m_DiffTools.Length == 0) && InternalEditorUtility.HasTeamLicense())
            {
                m_noDiffToolsMessage = InternalEditorUtility.GetNoDiffToolsDetectedMessage();
            }

            string diffTool = EditorPrefs.GetString("kDiffsDefaultApp");

            m_DiffToolIndex = ArrayUtility.IndexOf(m_DiffTools, diffTool);
            if (m_DiffToolIndex == -1)
            {
                m_DiffToolIndex = 0;
            }

            m_AutoRefresh = EditorPrefs.GetBool("kAutoRefresh");

            m_ReopenLastUsedProjectOnStartup = EditorPrefs.GetBool("ReopenLastUsedProjectOnStartup");

            m_UseOSColorPicker            = EditorPrefs.GetBool("UseOSColorPicker");
            m_EnableEditorAnalytics       = EditorPrefs.GetBool("EnableEditorAnalytics", true);
            m_ShowAssetStoreSearchHits    = EditorPrefs.GetBool("ShowAssetStoreSearchHits", true);
            m_VerifySavingAssets          = EditorPrefs.GetBool("VerifySavingAssets", false);
            m_ScriptCompilationDuringPlay = (ScriptChangesDuringPlayOptions)EditorPrefs.GetInt("ScriptCompilationDuringPlay", 0);
            m_DeveloperMode = Unsupported.IsDeveloperMode();

            m_GICacheSettings.m_EnableCustomPath = EditorPrefs.GetBool("GICacheEnableCustomPath");
            m_GICacheSettings.m_CachePath        = EditorPrefs.GetString("GICacheFolder");
            m_GICacheSettings.m_MaximumSize      = EditorPrefs.GetInt("GICacheMaximumSizeGB", 10);
            m_GICacheSettings.m_CompressionLevel = EditorPrefs.GetInt("GICacheCompressionLevel");

            m_SpriteAtlasCacheSize = EditorPrefs.GetInt("SpritePackerCacheMaximumSizeGB");

            m_AllowAttachedDebuggingOfEditor = EditorPrefs.GetBool("AllowAttachedDebuggingOfEditor", true);
            m_EnableEditorLocalization       = EditorPrefs.GetBool("Editor.kEnableEditorLocalization", true);
            m_SelectedLanguage           = EditorPrefs.GetString("Editor.kEditorLocale", LocalizationDatabase.GetDefaultEditorLanguage().ToString());
            m_AllowAlphaNumericHierarchy = EditorPrefs.GetBool("AllowAlphaNumericHierarchy", false);

            m_CompressAssetsOnImport = Unsupported.GetApplicationSettingCompressAssetsOnImport();
            m_GpuDevice = EditorPrefs.GetString("GpuDeviceName");

            foreach (IPreferenceWindowExtension extension in prefWinExtensions)
            {
                extension.ReadPreferences();
            }
        }