Inheritance: AssetPostprocessor
Exemplo n.º 1
0
 static SyncVS()
 {
     SyncVS.Synchronizer = new SolutionSynchronizer(Directory.GetParent(Application.dataPath).FullName, new SyncVS.SolutionSynchronizationSettings());
     EditorUserBuildSettings.activeBuildTargetChanged = (Action)Delegate.Combine(EditorUserBuildSettings.activeBuildTargetChanged, new Action(SyncVS.SyncVisualStudioProjectIfItAlreadyExists));
     try
     {
         SyncVS.InstalledVisualStudios = (SyncVS.GetInstalledVisualStudios() as Dictionary <VisualStudioVersion, string>);
     }
     catch (Exception ex)
     {
         Console.WriteLine("Error detecting Visual Studio installations: {0}{1}{2}", ex.Message, Environment.NewLine, ex.StackTrace);
         SyncVS.InstalledVisualStudios = new Dictionary <VisualStudioVersion, string>();
     }
     SyncVS.SetVisualStudioAsEditorIfNoEditorWasSet();
     UnityVSSupport.Initialize();
 }
Exemplo n.º 2
0
        private static IDictionary <VisualStudioVersion, string> GetInstalledVisualStudios()
        {
            Dictionary <VisualStudioVersion, string> dictionary = new Dictionary <VisualStudioVersion, string>();

            if (SyncVS.SolutionSynchronizationSettings.IsWindows)
            {
                using (IEnumerator enumerator = Enum.GetValues(typeof(VisualStudioVersion)).GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        VisualStudioVersion visualStudioVersion = (VisualStudioVersion)((int)enumerator.Current);
                        try
                        {
                            string text = Environment.GetEnvironmentVariable(string.Format("VS{0}0COMNTOOLS", (int)visualStudioVersion));
                            if (!string.IsNullOrEmpty(text))
                            {
                                string text2 = Paths.Combine(new string[]
                                {
                                    text,
                                    "..",
                                    "IDE",
                                    "devenv.exe"
                                });
                                if (File.Exists(text2))
                                {
                                    dictionary[visualStudioVersion] = text2;
                                    continue;
                                }
                            }
                            text = (Registry.GetValue(string.Format("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\{0}.0\\Debugger", (int)visualStudioVersion), "FEQARuntimeImplDll", null) as string);
                            if (!string.IsNullOrEmpty(text))
                            {
                                string text3 = SyncVS.DeriveVisualStudioPath(text);
                                if (!string.IsNullOrEmpty(text3) && File.Exists(text3))
                                {
                                    dictionary[visualStudioVersion] = SyncVS.DeriveVisualStudioPath(text);
                                }
                            }
                        }
                        catch
                        {
                        }
                    }
                }
            }
            return(dictionary);
        }
        // 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");
            ///@TODO: we need addedAssets for SyncVS. Make this into a proper API and write tests
            SyncVS.PostprocessSyncProject(importedAssets, addedAssets, deletedAssets, movedAssets, movedFromPathAssets);
            Profiler.EndSample();
        }
 private static void PostprocessAllAssets(string[] importedAssets, string[] addedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromPathAssets)
 {
     object[] parameters = new object[]
     {
         importedAssets,
         deletedAssets,
         movedAssets,
         movedFromPathAssets
     };
     foreach (Type current in EditorAssemblies.SubclassesOf(typeof(AssetPostprocessor)))
     {
         MethodInfo method = current.GetMethod("OnPostprocessAllAssets", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
         if (method != null)
         {
             method.Invoke(null, parameters);
         }
     }
     SyncVS.PostprocessSyncProject(importedAssets, addedAssets, deletedAssets, movedAssets, movedFromPathAssets);
 }
Exemplo n.º 5
0
        private static IDictionary <VisualStudioVersion, string> GetInstalledVisualStudios()
        {
            Dictionary <VisualStudioVersion, string> dictionary = new Dictionary <VisualStudioVersion, string>();

            if (SyncVS.SolutionSynchronizationSettings.IsWindows)
            {
                foreach (int num in Enum.GetValues(typeof(VisualStudioVersion)))
                {
                    VisualStudioVersion index = (VisualStudioVersion)num;
                    try
                    {
                        string environmentVariable = Environment.GetEnvironmentVariable(string.Format("VS{0}0COMNTOOLS", (object)index));
                        if (!string.IsNullOrEmpty(environmentVariable))
                        {
                            string path = Paths.Combine(environmentVariable, "..", "IDE", "devenv.exe");
                            if (File.Exists(path))
                            {
                                dictionary[index] = path;
                                continue;
                            }
                        }
                        string debuggerPath = Registry.GetValue(string.Format("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\{0}.0\\Debugger", (object)index), "FEQARuntimeImplDll", (object)null) as string;
                        if (!string.IsNullOrEmpty(debuggerPath))
                        {
                            string path = SyncVS.DeriveVisualStudioPath(debuggerPath);
                            if (!string.IsNullOrEmpty(path))
                            {
                                if (File.Exists(path))
                                {
                                    dictionary[index] = SyncVS.DeriveVisualStudioPath(debuggerPath);
                                }
                            }
                        }
                    }
                    catch
                    {
                    }
                }
            }
            return((IDictionary <VisualStudioVersion, string>)dictionary);
        }
Exemplo n.º 6
0
        private static string DeriveVisualStudioPath(string debuggerPath)
        {
            string a    = SyncVS.DeriveProgramFilesSentinel();
            string a2   = "Common7";
            bool   flag = false;

            string[] array = debuggerPath.Split(new char[]
            {
                Path.DirectorySeparatorChar,
                Path.AltDirectorySeparatorChar
            }, StringSplitOptions.RemoveEmptyEntries);
            string text = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);

            string[] array2 = array;
            for (int i = 0; i < array2.Length; i++)
            {
                string text2 = array2[i];
                if (!flag && string.Equals(a, text2, StringComparison.OrdinalIgnoreCase))
                {
                    flag = true;
                }
                else
                {
                    if (flag)
                    {
                        text = Path.Combine(text, text2);
                        if (string.Equals(a2, text2, StringComparison.OrdinalIgnoreCase))
                        {
                            break;
                        }
                    }
                }
            }
            return(Paths.Combine(new string[]
            {
                text,
                "IDE",
                "devenv.exe"
            }));
        }
Exemplo n.º 7
0
 private static void SyncAndOpenSolution()
 {
     SyncVS.SyncSolution();
     SyncVS.OpenProjectFileUnlessInBatchMode();
 }
Exemplo n.º 8
0
        private static IDictionary <VisualStudioVersion, VisualStudioPath[]> GetInstalledVisualStudios()
        {
            Dictionary <VisualStudioVersion, VisualStudioPath[]> dictionary = new Dictionary <VisualStudioVersion, VisualStudioPath[]>();

            if (SyncVS.SolutionSynchronizationSettings.IsWindows)
            {
                IEnumerator enumerator = Enum.GetValues(typeof(VisualStudioVersion)).GetEnumerator();
                try
                {
                    while (enumerator.MoveNext())
                    {
                        VisualStudioVersion visualStudioVersion = (VisualStudioVersion)enumerator.Current;
                        if (visualStudioVersion <= VisualStudioVersion.VisualStudio2015)
                        {
                            try
                            {
                                string text = Environment.GetEnvironmentVariable(string.Format("VS{0}0COMNTOOLS", (int)visualStudioVersion));
                                if (!string.IsNullOrEmpty(text))
                                {
                                    string path = Paths.Combine(new string[]
                                    {
                                        text,
                                        "..",
                                        "IDE",
                                        "devenv.exe"
                                    });
                                    if (File.Exists(path))
                                    {
                                        dictionary[visualStudioVersion] = new VisualStudioPath[]
                                        {
                                            new VisualStudioPath(path, "")
                                        };
                                        continue;
                                    }
                                }
                                text = SyncVS.GetRegistryValue(string.Format("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\{0}.0", (int)visualStudioVersion), "InstallDir");
                                if (string.IsNullOrEmpty(text))
                                {
                                    text = SyncVS.GetRegistryValue(string.Format("HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\Microsoft\\VisualStudio\\{0}.0", (int)visualStudioVersion), "InstallDir");
                                }
                                if (!string.IsNullOrEmpty(text))
                                {
                                    string path2 = Paths.Combine(new string[]
                                    {
                                        text,
                                        "devenv.exe"
                                    });
                                    if (File.Exists(path2))
                                    {
                                        dictionary[visualStudioVersion] = new VisualStudioPath[]
                                        {
                                            new VisualStudioPath(path2, "")
                                        };
                                        continue;
                                    }
                                }
                                text = SyncVS.GetRegistryValue(string.Format("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\{0}.0\\Debugger", (int)visualStudioVersion), "FEQARuntimeImplDll");
                                if (!string.IsNullOrEmpty(text))
                                {
                                    string text2 = SyncVS.DeriveVisualStudioPath(text);
                                    if (!string.IsNullOrEmpty(text2) && File.Exists(text2))
                                    {
                                        dictionary[visualStudioVersion] = new VisualStudioPath[]
                                        {
                                            new VisualStudioPath(SyncVS.DeriveVisualStudioPath(text), "")
                                        };
                                    }
                                }
                            }
                            catch
                            {
                            }
                        }
                    }
                }
                finally
                {
                    IDisposable disposable;
                    if ((disposable = (enumerator as IDisposable)) != null)
                    {
                        disposable.Dispose();
                    }
                }
                string[] array = VisualStudioUtil.FindVisualStudioDevEnvPaths(15, "Microsoft.VisualStudio.Workload.ManagedGame");
                if (array != null && array.Length > 0)
                {
                    VisualStudioPath[] array2 = new VisualStudioPath[array.Length / 2];
                    for (int i = 0; i < array.Length / 2; i++)
                    {
                        array2[i] = new VisualStudioPath(array[i * 2], array[i * 2 + 1]);
                    }
                    dictionary[VisualStudioVersion.VisualStudio2017] = array2;
                }
            }
            return(dictionary);
        }
Exemplo n.º 9
0
 public void OnActiveBuildTargetChanged(BuildTarget oldTarget, BuildTarget newTarget)
 {
     SyncVS.SyncVisualStudioProjectIfItAlreadyExists();
 }