예제 #1
0
        /// <summary>
        /// Called by the runtime when the editor is first started. Called after <see cref="OnInitialize"/>.
        /// </summary>
        static void OnEditorStartUp()
        {
            if (EditorSettings.AutoLoadLastProject)
            {
                string projectPath = EditorSettings.LastOpenProject;
                if (EditorApplication.IsValidProject(projectPath))
                {
                    EditorApplication.LoadProject(projectPath);
                }
                else
                {
                    ProjectWindow.Open();
                }
            }
            else
            {
                ProjectWindow.Open();
            }

            CodeEditorType activeCodeEditor = (CodeEditorType)EditorSettings.GetInt(SettingsWindow.ActiveCodeEditorKey, (int)CodeEditorType.None);

            CodeEditorType[] availableEditors = CodeEditor.AvailableEditors;
            if (Array.Exists(availableEditors, x => x == activeCodeEditor))
            {
                CodeEditor.ActiveEditor = activeCodeEditor;
            }
            else
            {
                if (availableEditors.Length > 0)
                {
                    CodeEditor.ActiveEditor = availableEditors[0];
                }
            }
        }
예제 #2
0
 public static void BrowseForProject()
 {
     ProjectWindow.Open();
 }
예제 #3
0
        /// <summary>
        /// Triggered by the runtime when <see cref="LoadProject"/> method completes.
        /// </summary>
        private static void Internal_OnProjectLoaded()
        {
            SetStatusProject(false);
            if (!unitTestsExecuted)
            {
                RunUnitTests();
                unitTestsExecuted = true;
            }

            if (!IsProjectLoaded)
            {
                ProjectWindow.Open();
                return;
            }

            string projectPath = ProjectPath;

            RecentProject[] recentProjects = EditorSettings.RecentProjects;
            bool            foundPath      = false;

            for (int i = 0; i < recentProjects.Length; i++)
            {
                if (PathEx.Compare(recentProjects[i].path, projectPath))
                {
                    recentProjects[i].accessTimestamp = (ulong)DateTime.Now.Ticks;
                    EditorSettings.RecentProjects     = recentProjects;
                    foundPath = true;
                    break;
                }
            }

            if (!foundPath)
            {
                List <RecentProject> extendedRecentProjects = new List <RecentProject>();
                extendedRecentProjects.AddRange(recentProjects);

                RecentProject newProject = new RecentProject();
                newProject.path            = projectPath;
                newProject.accessTimestamp = (ulong)DateTime.Now.Ticks;

                extendedRecentProjects.Add(newProject);

                EditorSettings.RecentProjects = extendedRecentProjects.ToArray();
            }

            EditorSettings.LastOpenProject = projectPath;
            EditorSettings.Save();

            ProjectLibrary.Refresh();

            if (monitor != null)
            {
                monitor.Destroy();
                monitor = null;
            }

            monitor             = new FolderMonitor(ProjectLibrary.ResourceFolder);
            monitor.OnAdded    += OnAssetModified;
            monitor.OnRemoved  += OnAssetModified;
            monitor.OnModified += OnAssetModified;

            if (!string.IsNullOrWhiteSpace(ProjectSettings.LastOpenScene))
            {
                lastLoadedScene = Scene.LoadAsync(ProjectSettings.LastOpenScene);
                SetSceneDirty(false);
            }
        }