コード例 #1
0
        private static IEnumerator SyncSolution()
        {
#if !DISABLE_UCE_ASSOCIATION
            FileWatcher.SyncSolution(false);
#else
            FileWatcher.SendSyncProjectRequests();
#endif
            // we don't want to loop forever here
            int count = 0;
            while (string.IsNullOrEmpty(SolutionPath) || count > 100)
            {
                yield return(new WaitForSeconds(1));

                count++;
                FindSolutionPath();
            }
            yield return(null);
        }
コード例 #2
0
        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());
        }