/// <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);
            }
        }
        /// <summary>
        /// Constructs a new editor application. Called at editor start-up by the runtime, and any time assembly refresh
        /// occurrs.
        /// </summary>
        internal EditorApplication()
        {
            instance    = this;
            codeManager = new ScriptCodeManager();

            const string soName = "EditorPersistentData";
            SceneObject  so     = Scene.Root.FindChild(soName);

            if (so == null)
            {
                so = new SceneObject(soName, true);
            }

            persistentData = so.GetComponent <EditorPersistentData>();
            if (persistentData == null)
            {
                persistentData = so.AddComponent <EditorPersistentData>();
            }

            // Register controls
            InputConfiguration inputConfig = VirtualInput.KeyConfig;

            inputConfig.RegisterButton(SceneCamera.MoveForwardBinding, ButtonCode.W);
            inputConfig.RegisterButton(SceneCamera.MoveBackBinding, ButtonCode.S);
            inputConfig.RegisterButton(SceneCamera.MoveLeftBinding, ButtonCode.A);
            inputConfig.RegisterButton(SceneCamera.MoveRightBinding, ButtonCode.D);
            inputConfig.RegisterButton(SceneCamera.MoveUpBinding, ButtonCode.E);
            inputConfig.RegisterButton(SceneCamera.MoveDownBinding, ButtonCode.Q);
            inputConfig.RegisterButton(SceneCamera.MoveForwardBinding, ButtonCode.Up);
            inputConfig.RegisterButton(SceneCamera.MoveBackBinding, ButtonCode.Down);
            inputConfig.RegisterButton(SceneCamera.MoveLeftBinding, ButtonCode.Left);
            inputConfig.RegisterButton(SceneCamera.MoveRightBinding, ButtonCode.Right);
            inputConfig.RegisterButton(SceneCamera.FastMoveBinding, ButtonCode.LeftShift);
            inputConfig.RegisterButton(SceneCamera.RotateBinding, ButtonCode.MouseRight);
            inputConfig.RegisterButton(SceneCamera.PanBinding, ButtonCode.MouseMiddle);
            inputConfig.RegisterAxis(SceneCamera.HorizontalAxisBinding, InputAxis.MouseX);
            inputConfig.RegisterAxis(SceneCamera.VerticalAxisBinding, InputAxis.MouseY);
            inputConfig.RegisterAxis(SceneCamera.ScrollAxisBinding, InputAxis.MouseZ);

            inputConfig.RegisterButton(SceneWindow.ToggleProfilerOverlayBinding, ButtonCode.P, ButtonModifier.CtrlAlt);
            inputConfig.RegisterButton(SceneWindow.ViewToolBinding, ButtonCode.Q);
            inputConfig.RegisterButton(SceneWindow.FrameBinding, ButtonCode.F);
            inputConfig.RegisterButton(SceneWindow.MoveToolBinding, ButtonCode.W);
            inputConfig.RegisterButton(SceneWindow.RotateToolBinding, ButtonCode.E);
            inputConfig.RegisterButton(SceneWindow.ScaleToolBinding, ButtonCode.R);
            inputConfig.RegisterButton(SceneWindow.DuplicateBinding, ButtonCode.D, ButtonModifier.Ctrl);

            if (IsProjectLoaded)
            {
                monitor             = new FolderMonitor(ProjectLibrary.ResourceFolder);
                monitor.OnAdded    += OnAssetModified;
                monitor.OnRemoved  += OnAssetModified;
                monitor.OnModified += OnAssetModified;
            }
        }
        /// <summary>
        /// Unloads the currently loaded project. Offers the user a chance to save the current scene if it is modified.
        /// Automatically saves all project data before unloading.
        /// </summary>
        private static void UnloadProject()
        {
            Action continueUnload =
                () =>
            {
                Scene.Clear();

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

                LibraryWindow window = EditorWindow.GetWindow <LibraryWindow>();
                if (window != null)
                {
                    window.Reset();
                }

                SetSceneDirty(false);
                Internal_UnloadProject();
                SetStatusProject(false);
            };

            Action <DialogBox.ResultType> dialogCallback =
                (result) =>
            {
                if (result == DialogBox.ResultType.Yes)
                {
                    SaveScene();
                }

                continueUnload();
            };

            if (IsSceneModified())
            {
                DialogBox.Open("Warning", "You current scene has modifications. Do you wish to save them first?",
                               DialogBox.Type.YesNoCancel, dialogCallback);
            }
            else
            {
                continueUnload();
            }
        }
Esempio n. 4
0
 private static extern void Internal_CreateInstance(FolderMonitor instance, string folder);
Esempio n. 5
0
        /// <summary>
        /// Constructs a new editor application. Called at editor start-up by the runtime, and any time assembly refresh
        /// occurrs.
        /// </summary>
        internal EditorApplication()
        {
            instance = this;
            codeManager = new ScriptCodeManager();

            const string soName = "EditorPersistentData";
            SceneObject so = Scene.Root.FindChild(soName);
            if (so == null)
                so = new SceneObject(soName, true);

            persistentData = so.GetComponent<EditorPersistentData>();
            if (persistentData == null)
                persistentData = so.AddComponent<EditorPersistentData>();

            // Register controls
            InputConfiguration inputConfig = VirtualInput.KeyConfig;

            inputConfig.RegisterButton(SceneCamera.MoveForwardBinding, ButtonCode.W);
            inputConfig.RegisterButton(SceneCamera.MoveBackBinding, ButtonCode.S);
            inputConfig.RegisterButton(SceneCamera.MoveLeftBinding, ButtonCode.A);
            inputConfig.RegisterButton(SceneCamera.MoveRightBinding, ButtonCode.D);
            inputConfig.RegisterButton(SceneCamera.MoveUpBinding, ButtonCode.E);
            inputConfig.RegisterButton(SceneCamera.MoveDownBinding, ButtonCode.Q);
            inputConfig.RegisterButton(SceneCamera.MoveForwardBinding, ButtonCode.Up);
            inputConfig.RegisterButton(SceneCamera.MoveBackBinding, ButtonCode.Down);
            inputConfig.RegisterButton(SceneCamera.MoveLeftBinding, ButtonCode.Left);
            inputConfig.RegisterButton(SceneCamera.MoveRightBinding, ButtonCode.Right);
            inputConfig.RegisterButton(SceneCamera.FastMoveBinding, ButtonCode.LeftShift);
            inputConfig.RegisterButton(SceneCamera.RotateBinding, ButtonCode.MouseRight);
            inputConfig.RegisterButton(SceneCamera.PanBinding, ButtonCode.MouseMiddle);
            inputConfig.RegisterAxis(SceneCamera.HorizontalAxisBinding, InputAxis.MouseX);
            inputConfig.RegisterAxis(SceneCamera.VerticalAxisBinding, InputAxis.MouseY);
            inputConfig.RegisterAxis(SceneCamera.ScrollAxisBinding, InputAxis.MouseZ);

            inputConfig.RegisterButton(SceneWindow.ToggleProfilerOverlayBinding, ButtonCode.P, ButtonModifier.CtrlAlt);
            inputConfig.RegisterButton(SceneWindow.ViewToolBinding, ButtonCode.Q);
            inputConfig.RegisterButton(SceneWindow.FrameBinding, ButtonCode.F);
            inputConfig.RegisterButton(SceneWindow.MoveToolBinding, ButtonCode.W);
            inputConfig.RegisterButton(SceneWindow.RotateToolBinding, ButtonCode.E);
            inputConfig.RegisterButton(SceneWindow.ScaleToolBinding, ButtonCode.R);

            inputConfig.RegisterButton(CutBinding, ButtonCode.X, ButtonModifier.Ctrl);
            inputConfig.RegisterButton(CopyBinding, ButtonCode.C, ButtonModifier.Ctrl);
            inputConfig.RegisterButton(PasteBinding, ButtonCode.V, ButtonModifier.Ctrl);
            inputConfig.RegisterButton(DuplicateBinding, ButtonCode.D, ButtonModifier.Ctrl);
            inputConfig.RegisterButton(DeleteBinding, ButtonCode.Delete);
            inputConfig.RegisterButton(RenameBinding, ButtonCode.F2);

            if (IsProjectLoaded)
            {
                monitor = new FolderMonitor(ProjectLibrary.ResourceFolder);
                monitor.OnAdded += OnAssetModified;
                monitor.OnRemoved += OnAssetModified;
                monitor.OnModified += OnAssetModified;
            }
        }
Esempio n. 6
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);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Unloads the currently loaded project. Offers the user a chance to save the current scene if it is modified.
        /// Automatically saves all project data before unloading.
        /// </summary>
        private static void UnloadProject()
        {
            Action continueUnload =
                () =>
                {
                    Scene.Clear();

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

                    LibraryWindow window = EditorWindow.GetWindow<LibraryWindow>();
                    if(window != null)
                        window.Reset();

                    SetSceneDirty(false);
                    Internal_UnloadProject();
                    SetStatusProject(false);
                };

            Action<DialogBox.ResultType> dialogCallback =
            (result) =>
            {
                if (result == DialogBox.ResultType.Yes)
                    SaveScene();

                continueUnload();
            };

            if (IsSceneModified())
            {
                DialogBox.Open("Warning", "You current scene has modifications. Do you wish to save them first?",
                    DialogBox.Type.YesNoCancel, dialogCallback);
            }
            else
                continueUnload();
        }
Esempio n. 8
0
 private static extern void Internal_CreateInstance(FolderMonitor instance, string folder);