コード例 #1
0
        internal void EndInit()
        {
            EnsureState <LoadingState>();
            Log("Editor end init");

            // Change state
            StateMachine.GoToState <EditingSceneState>();

            // Initialize modules (from front to back)
            for (int i = 0; i < _modules.Count; i++)
            {
                try
                {
                    _modules[i].OnEndInit();
                }
                catch (Exception ex)
                {
                    LogWarning(ex);
                    LogError("Failed to initialize editor module " + _modules[i]);
                }
            }
            _areModulesAfterInitEnd = true;

            InitializationEnd?.Invoke();

            // Close splash and show main window
            CloseSplashScreen();
            Assert.IsNotNull(Windows.MainWindow);
            if (!IsHeadlessMode)
            {
                Windows.MainWindow.Show();
                Windows.MainWindow.Focus();
            }

            // Load scene
            // TODO: loading last open scenes from Editor Cache
            {
                var defaultSceneAsset = ContentDatabase.Find(_projectInfo.DefaultSceneId);
                if (defaultSceneAsset is SceneItem)
                {
                    Editor.Log("Loading default project scene");
                    Scene.OpenScene(_projectInfo.DefaultSceneId);

                    // Use spawn point
                    Windows.EditWin.Viewport.ViewRay = _projectInfo.DefaultSceneSpawn;
                }
            }
        }
コード例 #2
0
ファイル: Editor.cs プロジェクト: djlw78/FlaxAPI
        internal void EndInit()
        {
            EnsureState <LoadingState>();
            Log("Editor end init");

            // Change state
            StateMachine.GoToState <EditingSceneState>();

            // Initialize modules (from front to back)
            for (int i = 0; i < _modules.Count; i++)
            {
                _modules[i].OnEndInit();
            }

            // Close splash and show main window
            CloseSplashScreen();
            Assert.IsNotNull(Windows.MainWindow);
            if (!IsHeadlessMode)
            {
                Windows.MainWindow.Show();
                Windows.MainWindow.Focus();
            }

            // Load scene
            // TODO: loading last open scenes from Editor Cache
            {
                var defaultSceneAsset = ContentDatabase.Find(_projectInfo.DefaultSceneId);
                if (defaultSceneAsset is SceneItem)
                {
                    Editor.Log("Loading default project scene");
                    Scene.OpenScene(_projectInfo.DefaultSceneId);

                    // Use spawn point
                    Windows.EditWin.Viewport.ViewPosition  = _projectInfo.DefaultSceneSpawn.Position;
                    Windows.EditWin.Viewport.ViewDirection = _projectInfo.DefaultSceneSpawn.Direction;
                }
            }
        }
コード例 #3
0
        internal void EndInit()
        {
            EnsureState <LoadingState>();
            Log("Editor end init");

            // Change state
            StateMachine.GoToState <EditingSceneState>();

            // Initialize modules (from front to back)
            for (int i = 0; i < _modules.Count; i++)
            {
                try
                {
                    _modules[i].OnEndInit();
                }
                catch (Exception ex)
                {
                    LogWarning(ex);
                    LogError("Failed to initialize editor module " + _modules[i]);
                }
            }
            _areModulesAfterInitEnd = true;
            _lastAutoSaveTimer      = Time.UnscaledGameTime;

            InitializationEnd?.Invoke();

            // Close splash and show main window
            CloseSplashScreen();
            Assert.IsNotNull(Windows.MainWindow);
            if (!IsHeadlessMode)
            {
                Windows.MainWindow.Show();
                Windows.MainWindow.Focus();
            }

            // Load scene
            var startupSceneMode = Options.Options.General.StartupSceneMode;

            if (startupSceneMode == GeneralOptions.StartupSceneModes.LastOpened && !ProjectCache.HasCustomData(ProjectDataLastScene))
            {
                // Fallback to default project scene if nothing saved in the cache
                startupSceneMode = GeneralOptions.StartupSceneModes.ProjectDefault;
            }
            switch (startupSceneMode)
            {
            case GeneralOptions.StartupSceneModes.ProjectDefault:
            {
                var defaultScene = ContentDatabase.Find(_projectInfo.DefaultSceneId);
                if (defaultScene is SceneItem)
                {
                    Editor.Log("Loading default project scene");
                    Scene.OpenScene(_projectInfo.DefaultSceneId);

                    // Use spawn point
                    Windows.EditWin.Viewport.ViewRay = _projectInfo.DefaultSceneSpawn;
                }
                break;
            }

            case GeneralOptions.StartupSceneModes.LastOpened:
            {
                if (ProjectCache.TryGetCustomData(ProjectDataLastScene, out var lastSceneIdName) && Guid.TryParse(lastSceneIdName, out var lastSceneId))
                {
                    var lastScene = ContentDatabase.Find(lastSceneId);
                    if (lastScene is SceneItem)
                    {
                        Editor.Log("Loading last opened scene");
                        Scene.OpenScene(lastSceneId);

                        // Restore view
                        if (ProjectCache.TryGetCustomData(ProjectDataLastSceneSpawn, out var lastSceneSpawnName))
                        {
                            Windows.EditWin.Viewport.ViewRay = JsonSerializer.Deserialize <Ray>(lastSceneSpawnName);
                        }
                    }
                }
                break;
            }
            }
        }