示例#1
0
        static RiderScriptEditor()
        {
            try
            {
                var projectGeneration = new ProjectGeneration();
                var editor            = new RiderScriptEditor(new Discovery(), projectGeneration);
                CodeEditor.Register(editor);

                var path = GetEditorRealPath(CodeEditor.CurrentEditorInstallation);
                if (IsRiderInstallation(path))
                {
                    if (!FileSystemUtil.EditorPathExists(path)) // previously used rider was removed
                    {
                        var newEditor = editor.Installations.Last().Path;
                        CodeEditor.SetExternalScriptEditor(newEditor);
                        path = newEditor;
                    }

                    editor.CreateSolutionIfDoesntExist();
                    if (ShouldLoadEditorPlugin(path))
                    {
                        editor.m_Initiliazer.Initialize(path);
                    }

                    InitProjectFilesWatcher();
                }
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }
        }
示例#2
0
        static RiderScriptEditor()
        {
            var projectGeneration = new ProjectGeneration();
            var editor            = new RiderScriptEditor(new Discovery(), projectGeneration);

            CodeEditor.Register(editor);
            if (IsRiderInstallation(CodeEditor.CurrentEditorInstallation))
            {
                editor.CreateIfDoesntExist();
                editor.m_Initiliazer.Initialize(CodeEditor.CurrentEditorInstallation);
            }
        }
        static RiderScriptEditor()
        {
            try
            {
                var projectGeneration = new ProjectGeneration();
                var editor            = new RiderScriptEditor(new Discovery(), projectGeneration);
                CodeEditor.Register(editor);
                var path = GetEditorRealPath(CodeEditor.CurrentEditorInstallation);

                if (IsRiderInstallation(path))
                {
                    if (!RiderScriptEditorData.instance.InitializedOnce)
                    {
                        var installations = editor.Installations;
                        // is toolbox and outdated - update
                        if (installations.Any() && RiderPathLocator.IsToolbox(path) && installations.All(a => a.Path != path))
                        {
                            var toolboxInstallations = installations.Where(a => a.Name.Contains("(JetBrains Toolbox)")).ToArray();
                            if (toolboxInstallations.Any())
                            {
                                var newEditor = toolboxInstallations.Last().Path;
                                CodeEditor.SetExternalScriptEditor(newEditor);
                                path = newEditor;
                            }
                            else
                            {
                                var newEditor = installations.Last().Path;
                                CodeEditor.SetExternalScriptEditor(newEditor);
                                path = newEditor;
                            }
                        }

                        // exists, is non toolbox and outdated - notify
                        if (installations.Any() && FileSystemUtil.EditorPathExists(path) && installations.All(a => a.Path != path))
                        {
                            var newEditorName = installations.Last().Name;
                            Debug.LogWarning($"Consider updating External Editor in Unity to Rider {newEditorName}.");
                        }

                        ShowWarningOnUnexpectedScriptEditor(path);
                        RiderScriptEditorData.instance.InitializedOnce = true;
                    }

                    if (!FileSystemUtil.EditorPathExists(path)) // previously used rider was removed
                    {
                        var installations = editor.Installations;
                        if (installations.Any())
                        {
                            var newEditor = installations.Last().Path;
                            CodeEditor.SetExternalScriptEditor(newEditor);
                            path = newEditor;
                        }
                    }
                    RiderScriptEditorData.instance.Init();

                    editor.CreateSolutionIfDoesntExist();
                    if (RiderScriptEditorData.instance.shouldLoadEditorPlugin)
                    {
                        editor.m_Initiliazer.Initialize(path);
                    }

                    InitProjectFilesWatcher();
                }
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }
        }
示例#4
0
        static RiderScriptEditor()
        {
            try
            {
                var projectGeneration = new ProjectGeneration();
                var editor            = new RiderScriptEditor(new Discovery(), projectGeneration);
                CodeEditor.Register(editor);
                var path = GetEditorRealPath(CurrentEditor);

                if (IsRiderInstallation(path))
                {
                    RiderPathLocator.RiderInfo[] installations = null;

                    if (!RiderScriptEditorData.instance.initializedOnce)
                    {
                        installations = RiderPathLocator.GetAllRiderPaths().OrderBy(a => a.BuildNumber).ToArray();
                        // is likely outdated
                        if (installations.Any() && installations.All(a => GetEditorRealPath(a.Path) != path))
                        {
                            if (RiderPathLocator.IsToolbox(path)) // is toolbox - update
                            {
                                var toolboxInstallations = installations.Where(a => a.IsToolbox).ToArray();
                                if (toolboxInstallations.Any())
                                {
                                    var newEditor = toolboxInstallations.Last().Path;
                                    CodeEditor.SetExternalScriptEditor(newEditor);
                                    path = newEditor;
                                }
                                else
                                {
                                    var newEditor = installations.Last().Path;
                                    CodeEditor.SetExternalScriptEditor(newEditor);
                                    path = newEditor;
                                }
                            }
                            else // is non toolbox - notify
                            {
                                var newEditorName = installations.Last().Presentation;
                                Debug.LogWarning($"Consider updating External Editor in Unity to Rider {newEditorName}.");
                            }
                        }

                        ShowWarningOnUnexpectedScriptEditor(path);
                        RiderScriptEditorData.instance.initializedOnce = true;
                    }

                    if (!FileSystemUtil.EditorPathExists(path)) // previously used rider was removed
                    {
                        if (installations == null)
                        {
                            installations = RiderPathLocator.GetAllRiderPaths().OrderBy(a => a.BuildNumber).ToArray();
                        }
                        if (installations.Any())
                        {
                            var newEditor = installations.Last().Path;
                            CodeEditor.SetExternalScriptEditor(newEditor);
                            path = newEditor;
                        }
                    }
                    RiderScriptEditorData.instance.Init();

                    editor.CreateSolutionIfDoesntExist();
                    if (RiderScriptEditorData.instance.shouldLoadEditorPlugin)
                    {
                        editor.m_Initiliazer.Initialize(path);
                    }

                    InitProjectFilesWatcher();
                }
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }
        }