private static void InitializeVisualStudio(string externalEditor) { if (externalEditor.EndsWith("UnityVS.OpenFile.exe")) { externalEditor = SyncVS.FindBestVisualStudio(); if (externalEditor != null) { ScriptEditorUtility.SetExternalScriptEditor(externalEditor); } } VisualStudioVersion version; if (UnityVSSupport.IsVisualStudio(externalEditor, out version)) { UnityVSSupport.m_ShouldUnityVSBeActive = true; string vstuBridgeAssembly = UnityVSSupport.GetVstuBridgeAssembly(version); if (vstuBridgeAssembly == null) { Console.WriteLine("Unable to find bridge dll in registry for Microsoft Visual Studio Tools for Unity for " + externalEditor); } else if (!File.Exists(vstuBridgeAssembly)) { Console.WriteLine("Unable to find bridge dll on disk for Microsoft Visual Studio Tools for Unity for " + vstuBridgeAssembly); } else { UnityVSSupport.s_UnityVSBridgeToLoad = vstuBridgeAssembly; InternalEditorUtility.RegisterPrecompiledAssembly(Path.GetFileNameWithoutExtension(vstuBridgeAssembly), vstuBridgeAssembly); } } }
public void Sync() { Profiler.BeginSample("SolutionSynchronizerSync"); // Do not sync solution until all Unity extensions are registered and initialized. // Otherwise Unity might emit errors when VSTU tries to generate the solution and // get all managed extensions, which not yet initialized. if (!InternalEditorUtility.IsUnityExtensionsInitialized()) { Profiler.EndSample(); return; } SetupProjectSupportedExtensions(); bool externalCodeAlreadyGeneratedProjects = AssetPostprocessingInternal.OnPreGeneratingCSProjectFiles(); if (!externalCodeAlreadyGeneratedProjects) { #pragma warning disable 618 var scriptEditor = ScriptEditorUtility.GetScriptEditorFromPreferences(); GenerateAndWriteSolutionAndProjects(scriptEditor); } AssetPostprocessingInternal.CallOnGeneratedCSProjectFiles(); Profiler.EndSample(); }
// Postprocess on all assets once an automatic import has completed static void PostprocessAllAssets(string[] importedAssets, string[] addedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromPathAssets) { bool profile = Profiler.enabled; object[] args = { importedAssets, deletedAssets, movedAssets, movedFromPathAssets }; foreach (var assetPostprocessorClass in GetCachedAssetPostprocessorClasses()) { MethodInfo method = assetPostprocessorClass.GetMethod("OnPostprocessAllAssets", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); if (method != null) { InvokeMethod(method, args); } } Profiler.BeginSample("SyncVS.PostprocessSyncProject"); #pragma warning disable 618 if (ScriptEditorUtility.GetScriptEditorFromPath(CodeEditor.CurrentEditorInstallation) == ScriptEditorUtility.ScriptEditor.Other) { CodeEditorProjectSync.PostprocessSyncProject(importedAssets, addedAssets, deletedAssets, movedAssets, movedFromPathAssets); } else { ///@TODO: we need addedAssets for SyncVS. Make this into a proper API and write tests SyncVS.PostprocessSyncProject(importedAssets, addedAssets, deletedAssets, movedAssets, movedFromPathAssets); } Profiler.EndSample(); }
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(); } }
static bool OnOpenAsset(int instanceID, int line, int column) { var selected = EditorUtility.InstanceIDToObject(instanceID); var assetPath = AssetDatabase.GetAssetPath(selected); #pragma warning disable 618 if (ScriptEditorUtility.GetScriptEditorFromPath(CurrentEditorInstallation) != ScriptEditorUtility.ScriptEditor.Other) { return(false); } if (string.IsNullOrEmpty(assetPath)) { return(false); } var assetFilePath = Path.GetFullPath(assetPath); var assetExtension = Path.GetExtension(assetFilePath); if (string.IsNullOrEmpty(assetExtension)) { return(false); } if (!(selected.GetType().ToString() == "UnityEditor.MonoScript" || selected.GetType().ToString() == "UnityEngine.Shader" || selected.GetType().ToString() == "UnityEngine.Experimental.UIElements.VisualTreeAsset" || selected.GetType().ToString() == "UnityEngine.StyleSheets.StyleSheet" || GetExtensionStrings().Contains(assetExtension.Substring(1)) )) { return(false); } return(Editor.Current.OpenProject(assetFilePath, line, column)); }
private static void InitializeVisualStudio(string externalEditor) { if (externalEditor.EndsWith("UnityVS.OpenFile.exe")) { externalEditor = SyncVS.FindBestVisualStudio(); if (externalEditor != null) { ScriptEditorUtility.SetExternalScriptEditor(externalEditor); } } VisualStudioVersion vsVersion; if (!IsVisualStudio(externalEditor, out vsVersion)) { return; } m_ShouldUnityVSBeActive = true; var bridgeFile = GetVstuBridgeAssembly(vsVersion); if (bridgeFile == null) { Console.WriteLine("Unable to find bridge dll in registry for Microsoft Visual Studio Tools for Unity for " + externalEditor); return; } if (!File.Exists(bridgeFile)) { Console.WriteLine("Unable to find bridge dll on disk for Microsoft Visual Studio Tools for Unity for " + bridgeFile); return; } s_UnityVSBridgeToLoad = bridgeFile; InternalEditorUtility.RegisterPrecompiledAssembly(Path.GetFileNameWithoutExtension(bridgeFile), bridgeFile); }
public void Sync() { this.SetupProjectSupportedExtensions(); if (!AssetPostprocessingInternal.OnPreGeneratingCSProjectFiles()) { ScriptEditorUtility.ScriptEditor scriptEditorFromPreferences = ScriptEditorUtility.GetScriptEditorFromPreferences(); if (scriptEditorFromPreferences == ScriptEditorUtility.ScriptEditor.SystemDefault || scriptEditorFromPreferences == ScriptEditorUtility.ScriptEditor.Other) { return; } IEnumerable <MonoIsland> islands = from i in EditorCompilationInterface.GetAllMonoIslands() where 0 < i._files.Length && i._files.Any((string f) => this.ShouldFileBePartOfSolution(f)) select i; Dictionary <string, string> allAssetsProjectParts = this.GenerateAllAssetProjectParts(); string[] responseFileDefinesFromFile = ScriptCompilerBase.GetResponseFileDefinesFromFile(MonoCSharpCompiler.ReponseFilename); this.SyncSolution(islands); List <MonoIsland> list = SolutionSynchronizer.RelevantIslandsForMode(islands, SolutionSynchronizer.ModeForCurrentExternalEditor()).ToList <MonoIsland>(); foreach (MonoIsland current in list) { this.SyncProject(current, allAssetsProjectParts, responseFileDefinesFromFile, list); } if (scriptEditorFromPreferences == ScriptEditorUtility.ScriptEditor.VisualStudioCode) { this.WriteVSCodeSettingsFiles(); } } AssetPostprocessingInternal.CallOnGeneratedCSProjectFiles(); }
private void WritePreferences() { ScriptEditorUtility.SetExternalScriptEditor(m_ScriptEditorPath); ScriptEditorUtility.SetExternalScriptEditorArgs(m_ScriptEditorArgs); EditorPrefs.SetBool("kExternalEditorSupportsUnityProj", m_ExternalEditorSupportsUnityProj); EditorPrefs.SetString("kImagesDefaultApp", m_ImageAppPath); EditorPrefs.SetString("kDiffsDefaultApp", m_DiffTools.Length == 0 ? "" : m_DiffTools[m_DiffToolIndex]); WriteRecentAppsList(m_ScriptApps, m_ScriptEditorPath, kRecentScriptAppsKey); WriteRecentAppsList(m_ImageApps, m_ImageAppPath, kRecentImageAppsKey); EditorPrefs.SetBool("kAutoRefresh", m_AutoRefresh); if (Unsupported.IsDeveloperMode() || UnityConnect.preferencesEnabled) { UnityConnectPrefs.StorePanelPrefs(); } EditorPrefs.SetBool("ReopenLastUsedProjectOnStartup", m_ReopenLastUsedProjectOnStartup); EditorPrefs.SetBool("UseOSColorPicker", m_UseOSColorPicker); EditorPrefs.SetBool("EnableEditorAnalytics", m_EnableEditorAnalytics); EditorPrefs.SetBool("ShowAssetStoreSearchHits", m_ShowAssetStoreSearchHits); EditorPrefs.SetBool("VerifySavingAssets", m_VerifySavingAssets); EditorPrefs.SetInt("ScriptCompilationDuringPlay", (int)m_ScriptCompilationDuringPlay); // The Preferences window always writes all preferences, we don't want this behavior since we // want the default value to just match "IsSourceBuild" until the developer has explicitly changed it. if (m_DeveloperModeDirty) { EditorPrefs.SetBool("DeveloperMode", m_DeveloperMode); // Repaint all views to show/hide debug repaint indicator InternalEditorUtility.RepaintAllViews(); } EditorPrefs.SetBool("AllowAttachedDebuggingOfEditor", m_AllowAttachedDebuggingOfEditor); EditorPrefs.SetBool("Editor.kEnableEditorLocalization", m_EnableEditorLocalization); EditorPrefs.SetString("Editor.kEditorLocale", m_SelectedLanguage); EditorPrefs.SetBool("AllowAlphaNumericHierarchy", m_AllowAlphaNumericHierarchy); EditorPrefs.SetString("GpuDeviceName", m_GpuDevice); EditorPrefs.SetBool("GICacheEnableCustomPath", m_GICacheSettings.m_EnableCustomPath); EditorPrefs.SetInt("GICacheMaximumSizeGB", m_GICacheSettings.m_MaximumSize); EditorPrefs.SetString("GICacheFolder", m_GICacheSettings.m_CachePath); EditorPrefs.SetInt("GICacheCompressionLevel", m_GICacheSettings.m_CompressionLevel); EditorPrefs.SetInt("SpritePackerCacheMaximumSizeGB", m_SpriteAtlasCacheSize); foreach (IPreferenceWindowExtension extension in prefWinExtensions) { extension.WritePreferences(); } UnityEditor.Lightmapping.UpdateCachePath(); }
private string ProjectHeader(MonoIsland island, string[] additionalDefines) { string text = "v3.5"; string text2 = "4"; string text3 = "4.0"; string text4 = "10.0.20506"; string text5 = "."; ScriptingLanguage language = SolutionSynchronizer.ScriptingLanguageFor(island); if (PlayerSettingsEditor.IsLatestApiCompatibility(island._api_compatibility_level)) { text = "v4.6"; text2 = "6"; } else if (ScriptEditorUtility.GetScriptEditorFromPreferences() == ScriptEditorUtility.ScriptEditor.Rider) { text = "v4.5"; } else if (this._settings.VisualStudioVersion == 9) { text3 = "3.5"; text4 = "9.0.21022"; } object[] array = new object[] { text3, text4, this.ProjectGuid(island._output), this._settings.EngineAssemblyPath, this._settings.EditorAssemblyPath, string.Join(";", new string[] { "DEBUG", "TRACE" }.Concat(this._settings.Defines).Concat(island._defines).Concat(additionalDefines).Distinct <string>().ToArray <string>()), SolutionSynchronizer.MSBuildNamespaceUri, Path.GetFileNameWithoutExtension(island._output), EditorSettings.projectGenerationRootNamespace, text, text2, text5 }; string result; try { result = string.Format(this._settings.GetProjectHeaderTemplate(language), array); } catch (Exception) { throw new NotSupportedException("Failed creating c# project because the c# project header did not have the correct amount of arguments, which is " + array.Length); } return(result); }
private string ProjectHeader(MonoIsland island, ScriptCompilerBase.ResponseFileData responseFileData) { string targetframeworkversion = "v3.5"; string targetLanguageVersion = "4"; string toolsversion = "4.0"; string productversion = "10.0.20506"; string baseDirectory = "."; ScriptingLanguage language = ScriptingLanguageFor(island); if (PlayerSettingsEditor.IsLatestApiCompatibility(island._api_compatibility_level)) { if (ScriptEditorUtility.GetScriptEditorFromPreferences() == ScriptEditorUtility.ScriptEditor.Rider || ScriptEditorUtility.GetScriptEditorFromPreferences() == ScriptEditorUtility.ScriptEditor.VisualStudioCode) { targetframeworkversion = "v4.5"; } else { targetframeworkversion = "v4.7.1"; } targetLanguageVersion = "7.2"; } else if (_settings.VisualStudioVersion == 9) { toolsversion = "3.5"; productversion = "9.0.21022"; } var arguments = new object[] { toolsversion, productversion, ProjectGuid(island._output), _settings.EngineAssemblyPath, _settings.EditorAssemblyPath, string.Join(";", new[] { "DEBUG", "TRACE" }.Concat(island._defines).Concat(responseFileData.Defines).Distinct().ToArray()), MSBuildNamespaceUri, Path.GetFileNameWithoutExtension(island._output), EditorSettings.projectGenerationRootNamespace, targetframeworkversion, targetLanguageVersion, baseDirectory, island._allowUnsafeCode | responseFileData.Unsafe }; try { return(string.Format(_settings.GetProjectHeaderTemplate(language), arguments)); } catch (Exception) { throw new System.NotSupportedException("Failed creating c# project because the c# project header did not have the correct amount of arguments, which is " + arguments.Length); } }
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); }); } }
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); } }
private static Mode ModeForCurrentExternalEditor() { #pragma warning disable 618 var scriptEditor = ScriptEditorUtility.GetScriptEditorFromPreferences(); if (scriptEditor == ScriptEditorUtility.ScriptEditor.VisualStudio || scriptEditor == ScriptEditorUtility.ScriptEditor.VisualStudioExpress) { return(Mode.UnityScriptAsPrecompiledAssembly); } return(EditorPrefs.GetBool("kExternalEditorSupportsUnityProj", false) ? Mode.UnityScriptAsUnityProj : Mode.UnityScriptAsPrecompiledAssembly); }
public static void SyncVisualStudioProjectIfItAlreadyExists() { if (!s_Enabled) { return; } #pragma warning disable 618 if (Synchronizer.SolutionExists() && ScriptEditorUtility.GetScriptEditorFromPath(CodeEditor.CurrentEditorInstallation) != ScriptEditorUtility.ScriptEditor.Other) { Synchronizer.Sync(); } }
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(); }
public void Sync() { SetupProjectSupportedExtensions(); bool externalCodeAlreadyGeneratedProjects = AssetPostprocessingInternal.OnPreGeneratingCSProjectFiles(); if (!externalCodeAlreadyGeneratedProjects) { var scriptEditor = ScriptEditorUtility.GetScriptEditorFromPreferences(); GenerateAndWriteSolutionAndProjects(scriptEditor); } AssetPostprocessingInternal.CallOnGeneratedCSProjectFiles(); }
private static SolutionSynchronizer.Mode ModeForCurrentExternalEditor() { ScriptEditorUtility.ScriptEditor scriptEditorFromPreferences = ScriptEditorUtility.GetScriptEditorFromPreferences(); SolutionSynchronizer.Mode result; if (scriptEditorFromPreferences == ScriptEditorUtility.ScriptEditor.VisualStudio || scriptEditorFromPreferences == ScriptEditorUtility.ScriptEditor.VisualStudioExpress || scriptEditorFromPreferences == ScriptEditorUtility.ScriptEditor.VisualStudioCode) { result = SolutionSynchronizer.Mode.UnityScriptAsPrecompiledAssembly; } else { result = ((!EditorPrefs.GetBool("kExternalEditorSupportsUnityProj", false)) ? SolutionSynchronizer.Mode.UnityScriptAsPrecompiledAssembly : SolutionSynchronizer.Mode.UnityScriptAsUnityProj); } return(result); }
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 static void SyncSolution() { // Ensure that the mono islands are up-to-date AssetDatabase.Refresh(); // TODO: Rider and possibly other code editors, use reflection to call this method. // To avoid conflicts and null reference exception, this is left as a dummy method. Unity.CodeEditor.CodeEditor.Editor.Current.SyncAll(); #pragma warning disable 618 if (ScriptEditorUtility.GetScriptEditorFromPath(CodeEditor.CurrentEditorInstallation) != ScriptEditorUtility.ScriptEditor.Other) { Synchronizer.Sync(); } }
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); } }
static void SyncAndOpenSolution() { // Ensure that the mono islands are up-to-date AssetDatabase.Refresh(); #pragma warning disable 618 if (ScriptEditorUtility.GetScriptEditorFromPath(CodeEditor.CurrentEditorInstallation) == ScriptEditorUtility.ScriptEditor.Other) { CodeEditor.Editor.Current.SyncAll(); } else { SyncVS.Synchronizer.Sync(); } OpenProjectFileUnlessInBatchMode(); }
static void OpenProjectFileUnlessInBatchMode() { if (InternalEditorUtility.inBatchMode) { return; } #pragma warning disable 618 if (ScriptEditorUtility.GetScriptEditorFromPath(CodeEditor.CurrentEditorInstallation) == ScriptEditorUtility.ScriptEditor.Other) { CodeEditor.Editor.Current.OpenProject(); } else { InternalEditorUtility.OpenFileAtLineExternal("", -1, -1); } }
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); }
internal Dictionary <string, string> GetFoundScriptEditorPaths() { var result = new Dictionary <string, string>(); #pragma warning disable 618 if (ScriptEditorUtility.GetScriptEditorFromPath(CurrentEditorInstallation) != ScriptEditorUtility.ScriptEditor.Other && Application.platform == RuntimePlatform.OSXEditor) { AddIfPathExists("Visual Studio", "/Applications/Visual Studio.app", result); AddIfPathExists("Visual Studio (Preview)", "/Applications/Visual Studio (Preview).app", result); } foreach (var installation in m_ExternalCodeEditors.SelectMany(codeEditor => codeEditor.Installations)) { AddIfPathExists(installation.Name, installation.Path, result); } return(result); }
static bool OnOpenAsset(int instanceID, int line, int column) { var selected = EditorUtility.InstanceIDToObject(instanceID); var assetPath = AssetDatabase.GetAssetPath(selected); #pragma warning disable 618 if (ScriptEditorUtility.GetScriptEditorFromPath(CurrentEditorInstallation) != ScriptEditorUtility.ScriptEditor.Other) { return(false); } if (string.IsNullOrEmpty(assetPath)) { return(false); } var assetFilePath = Path.GetFullPath(assetPath); return(Editor.Current.OpenProject(assetFilePath, line, column)); }
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); }
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(); } }
private static bool IsVSForMac(string externalEditor, out Version vsfmVersion) { vsfmVersion = null; if (!ScriptEditorUtility.IsVisualStudioForMac(externalEditor)) { return(false); } // We need to extract the version used by VS for Mac // to lookup its addin registry try { return(GetVSForMacVersion(externalEditor, out vsfmVersion)); } catch (Exception e) { Console.WriteLine("Failed to read Visual Studio for Mac information: {0}", e); return(false); } }
public void Sync() { SetupProjectSupportedExtensions(); bool externalCodeAlreadyGeneratedProjects = AssetPostprocessingInternal.OnPreGeneratingCSProjectFiles(); if (!externalCodeAlreadyGeneratedProjects) { var scriptEditor = ScriptEditorUtility.GetScriptEditorFromPreferences(); // Do not generate .sln and .csproj for unsupported code editors. if (scriptEditor == ScriptEditorUtility.ScriptEditor.SystemDefault || scriptEditor == ScriptEditorUtility.ScriptEditor.Other) { return; } GenerateAndWriteSolutionAndProjects(scriptEditor); } AssetPostprocessingInternal.CallOnGeneratedCSProjectFiles(); }
public void Sync() { this.SetupProjectSupportedExtensions(); if (!AssetPostprocessingInternal.OnPreGeneratingCSProjectFiles()) { IEnumerable <MonoIsland> islands = from i in InternalEditorUtility.GetMonoIslands() where 0 < i._files.Length select i; string otherAssetsProjectPart = this.GenerateAllAssetProjectPart(); string[] responseFileDefinesFromFile = ScriptCompilerBase.GetResponseFileDefinesFromFile(MonoCSharpCompiler.ReponseFilename); this.SyncSolution(islands); foreach (MonoIsland current in SolutionSynchronizer.RelevantIslandsForMode(islands, SolutionSynchronizer.ModeForCurrentExternalEditor())) { this.SyncProject(current, otherAssetsProjectPart, responseFileDefinesFromFile); } if (ScriptEditorUtility.GetScriptEditorFromPreferences() == ScriptEditorUtility.ScriptEditor.VisualStudioCode) { this.WriteVSCodeSettingsFiles(); } } AssetPostprocessingInternal.CallOnGeneratedCSProjectFiles(); }