/// <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();
            monitor             = new FolderMonitor(ProjectLibrary.ResourceFolder);
            monitor.OnAdded    += OnAssetModified;
            monitor.OnRemoved  += OnAssetModified;
            monitor.OnModified += OnAssetModified;

            if (!string.IsNullOrWhiteSpace(ProjectSettings.LastOpenScene))
            {
                Scene.Load(ProjectSettings.LastOpenScene);
                SetSceneDirty(false);
            }
        }
Example #2
0
        /// <summary>
        /// Attempts to open a project at the path currently entered in the project path input box.
        /// </summary>
        private void OpenProject()
        {
            string projectPath = projectInputBox.Value;

            if (EditorApplication.IsValidProject(projectPath))
            {
                EditorSettings.AutoLoadLastProject = autoLoadToggle.Value;

                Close();
                EditorApplication.LoadProject(projectPath);
            }
            else
            {
                // Remove invalid project from recent projects list
                RecentProject[] recentProjects = EditorSettings.RecentProjects;
                for (int i = 0; i < recentProjects.Length; i++)
                {
                    if (PathEx.Compare(recentProjects[i].path, projectPath))
                    {
                        RecentProject[] newRecentProjects = new RecentProject[recentProjects.Length - 1];
                        int             idx = 0;
                        for (int j = 0; j < recentProjects.Length; j++)
                        {
                            if (i == j)
                            {
                                continue;
                            }

                            newRecentProjects[idx] = recentProjects[j];
                            idx++;
                        }

                        EditorSettings.RecentProjects = newRecentProjects;
                        EditorSettings.Save();
                        RefreshRecentProjects();

                        break;
                    }
                }

                // Warn user
                LocString message = new LocEdString("Provided project path \"{0}\" doesn't contain a valid project.");
                message.SetParameter(0, projectPath);

                DialogBox.Open(new LocEdString("Error"), message, DialogBox.Type.OK);
            }
        }
        /// <summary>
        /// Attempts to open a project at the path currently entered in the project path input box.
        /// </summary>
        private void OpenProject()
        {
            string projectPath = projectInputBox.Value;

            if (EditorApplication.IsValidProject(projectPath))
            {
                EditorSettings.AutoLoadLastProject = autoLoadToggle.Value;

                Close();
                EditorApplication.LoadProject(projectPath);
            }
            else
            {
                // Remove invalid project from recent projects list
                RecentProject[] recentProjects = EditorSettings.RecentProjects;
                for (int i = 0; i < recentProjects.Length; i++)
                {
                    if (PathEx.Compare(recentProjects[i].path, projectPath))
                    {
                        RecentProject[] newRecentProjects = new RecentProject[recentProjects.Length - 1];
                        int idx = 0;
                        for (int j = 0; j < recentProjects.Length; j++)
                        {
                            if (i == j)
                                continue;

                            newRecentProjects[idx] = recentProjects[j];
                            idx++;
                        }

                        EditorSettings.RecentProjects = newRecentProjects;
                        EditorSettings.Save();
                        RefreshRecentProjects();

                        break;
                    }
                }

                // Warn user
                LocString message = new LocEdString("Provided project path \"{0}\" doesn't contain a valid project.");
                message.SetParameter(0, projectPath);

                DialogBox.Open(new LocEdString("Error"), message, DialogBox.Type.OK);
            }
        }
Example #4
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();
            monitor = new FolderMonitor(ProjectLibrary.ResourceFolder);
            monitor.OnAdded += OnAssetModified;
            monitor.OnRemoved += OnAssetModified;
            monitor.OnModified += OnAssetModified;

            if (!string.IsNullOrWhiteSpace(ProjectSettings.LastOpenScene))
            {
                Scene.Load(ProjectSettings.LastOpenScene);
                SetSceneDirty(false);
            }
        }