static OnLoad() { SetDefaultScriptEditor(); EditorUtility.ClearProgressBar(); UCE_FOLDER_IN_PROJECT = PathManager.GetUCEFolderInProject(); EditorCoroutine.StartCoroutine(SyncSolution()); Utility.Log(string.Format("OmniSharpManager.CheckIfOmnisharpNeedsUpgrade = {0}", OmniSharpManager.CheckIfOmnisharpNeedsUpgrade())); if (!OmniSharpManager.CheckInstallationExists()) { OmniSharpManager.InstallOmnisharp(); } else if (OmniSharpManager.CheckIfOmnisharpNeedsUpgrade()) { OmniSharpManager.UpdateOmnisharp(); } MONO_PATH = MonoHelper.GetMonoLocation(); STDIO_BRIDGE_PATH = GetStdioBridgePath(); WORKING_DIRECTORY = Application.dataPath; PROCESS_ID = Process.GetCurrentProcess().Id; OMNISHARP_LOCK = PathManager.OmnisharpRestartLockFile(); STDIO_THREAD = new Thread(new ThreadStart(LanuchOmniSharp)); STDIO_THREAD.Start(); EditorApplication.update += FileSearch.Update; Undo.undoRedoPerformed += UndoRedoPerformed; }
public static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) { bool hasCSFileChanged = false; bool needRestartOmnisharp = false; HandleAction action = (string path, string type, bool hasRemoveAction, string oldFile) => { FileChangedWithAllowedCheck(path, type, oldFile); if (!hasCSFileChanged) { hasCSFileChanged = Utility.IsCSharpScript(path); } // WORKAROUND: If have rename action for cs file, we need to restart Omnisharp // to take the intellisense back. if (!string.IsNullOrEmpty(oldFile) && !needRestartOmnisharp) { needRestartOmnisharp = Utility.IsCSharpScript(oldFile); if (needRestartOmnisharp) { var lockFile = PathManager.OmnisharpRestartLockFile(); if (!File.Exists(lockFile)) { File.WriteAllText(PathManager.OmnisharpRestartLockFile(), ""); } } } if (hasRemoveAction) { if (Utility.IsFileAllowed(path)) { ALLOWED_FILES_CACHE.Add(Path.GetFullPath(path)); } if (!string.IsNullOrEmpty(oldFile)) { ALLOWED_FILES_CACHE.Remove(Path.GetFullPath(oldFile)); } } else { if (Utility.IsFileAllowed(path)) { ALLOWED_FILES_CACHE.Add(Path.GetFullPath(path)); } } }; foreach (string path in deletedAssets) { Utility.Log("deleting " + path); action(path, "delete", true); } for (int i = 0; i < movedAssets.Length; i++) { Utility.Log(string.Format("move {0} to {1}", movedFromAssetPaths[i], movedAssets[i])); action(movedAssets[i], "rename", true, movedFromAssetPaths[i]); } foreach (string path in importedAssets) { Utility.Log("chaning " + path); action(path, "change", false); } Utility.Log("hasCSFileChanged = " + hasCSFileChanged); if (hasCSFileChanged) { #if !DISABLE_UCE_ASSOCIATION FileWatcher.SyncSolution(); #else FileWatcher.SendSyncProjectRequests(); #endif } File.WriteAllLines(PathManager.GetGoToFileCachePath(), ALLOWED_FILES_CACHE.ToArray()); }