public static void Initialize(string editorPath)
        {
            if (Application.platform != RuntimePlatform.WindowsEditor)
            {
                return;
            }
            string externalEditor = editorPath ?? EditorPrefs.GetString("kScriptsDefaultApp");

            if (externalEditor.EndsWith("UnityVS.OpenFile.exe"))
            {
                externalEditor = SyncVS.FindBestVisualStudio();
                if (externalEditor != null)
                {
                    EditorPrefs.SetString("kScriptsDefaultApp", externalEditor);
                }
            }
            KeyValuePair <VisualStudioVersion, string>[] array = (from kvp in SyncVS.InstalledVisualStudios
                                                                  where Paths.AreEqual(kvp.Value, externalEditor, true)
                                                                  select kvp).ToArray <KeyValuePair <VisualStudioVersion, string> >();
            bool flag = array.Length > 0;

            UnityVSSupport.m_ShouldUnityVSBeActive = flag;
            if (!flag)
            {
                return;
            }
            string vstuBridgeAssembly = UnityVSSupport.GetVstuBridgeAssembly(array[0].Key);

            if (vstuBridgeAssembly == null)
            {
                Console.WriteLine("Unable to find bridge dll in registry for Microsoft Visual Studio Tools for Unity for " + externalEditor);
                return;
            }
            if (!File.Exists(vstuBridgeAssembly))
            {
                Console.WriteLine("Unable to find bridge dll on disk for Microsoft Visual Studio Tools for Unity for " + vstuBridgeAssembly);
                return;
            }
            UnityVSSupport.s_LoadedUnityVS = vstuBridgeAssembly;
            InternalEditorUtility.SetupCustomDll(Path.GetFileNameWithoutExtension(vstuBridgeAssembly), vstuBridgeAssembly);
        }
Beispiel #2
0
        static Paths()
        {
            assets         = Application.dataPath;
            editor         = EditorApplication.applicationPath;
            editorContents = EditorApplication.applicationContentsPath;

            try
            {
                SyncVS = typeof(Editor).Assembly.GetType("UnityEditor.SyncVS", true);
                SyncVS_SyncSolution = SyncVS.GetMethod("SyncSolution", BindingFlags.Static | BindingFlags.Public);

                if (SyncVS_SyncSolution == null)
                {
                    throw new MissingMemberException(SyncVS.ToString(), "SyncSolution");
                }
            }
            catch (Exception ex)
            {
                throw new UnityEditorInternalException(ex);
            }
        }
        public static void Initialize(string editorPath)
        {
            if (Application.platform != RuntimePlatform.WindowsEditor)
            {
                return;
            }
            string text = editorPath ?? EditorPrefs.GetString("kScriptsDefaultApp");

            if (text.EndsWith("UnityVS.OpenFile.exe"))
            {
                text = SyncVS.FindBestVisualStudio();
                if (text != null)
                {
                    EditorPrefs.SetString("kScriptsDefaultApp", text);
                }
            }
            VisualStudioVersion version;

            if (!UnityVSSupport.IsVisualStudio(text, out version))
            {
                return;
            }
            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 " + text);
                return;
            }
            if (!File.Exists(vstuBridgeAssembly))
            {
                Console.WriteLine("Unable to find bridge dll on disk for Microsoft Visual Studio Tools for Unity for " + vstuBridgeAssembly);
                return;
            }
            UnityVSSupport.s_UnityVSBridgeToLoad = vstuBridgeAssembly;
            InternalEditorUtility.SetupCustomDll(Path.GetFileNameWithoutExtension(vstuBridgeAssembly), vstuBridgeAssembly);
        }
 public static void SyncSolution()
 {
     SyncVS.SyncSolution();
 }