コード例 #1
0
        internal static void OpenedScene(Scene myNewScene, OpenSceneMode mode)
        {
            if (newScene == myNewScene.path && !_comingFromNewScene)
            {
                return;
            }

            _previousScene = _lastScene;
            _lastScene     = myNewScene.path;

            var now         = System.DateTime.Now;
            var lastOpened  = $"{now.ToShortDateString()} at {now.ToShortTimeString()}";
            var recentScene = new RecentScene(myNewScene, instance, lastOpened);

            if (recentScene.data != null)
            {
                recentScene.data.Save();
            }


            pathAndScene[myNewScene.path] = recentScene;
            newScene = myNewScene.path;

            if (instance == null)
            {
                instance = ScriptableObject.CreateInstance <RecentSceneData>();
            }

            UpdatePreviousScenes();
        }
コード例 #2
0
        internal static void SceneClosed(Scene closingScene)
        {
            if (!pathAndScene.ContainsKey(closingScene.path))
            {
                return;
            }

            if (instance == null)
            {
                instance = ScriptableObject.CreateInstance <RecentSceneData>();
            }

            var originalScene = pathAndScene.ContainsKey(closingScene.path)
                ? pathAndScene[closingScene.path]
                : new RecentScene(closingScene, instance);

            var scene = new RecentScene(closingScene, instance, originalScene.lastOpened);

            pathAndScene[closingScene.path] = scene;
        }
コード例 #3
0
        internal RecentScene(Scene scene, ScriptableObject obj, string openDate = "", bool creatingNew = false)
        {
            path       = scene.path;
            name       = scene.name;
            objCount   = GetSceneObjCount(scene);
            lastOpened = openDate;
            if (scene.isLoaded && RecentSceneManager.trackScenePreview)
            {
                _scenePreview = SetScenePreview(scene, obj);
            }
            else
            {
                _scenePreview = GetScenePreview(obj, scene.name);
            }

            data = null;

            if (RecentSceneManager.trackEditedBy && !string.IsNullOrWhiteSpace(name))
            {
                data = GetDataObj(creatingNew);
            }
        }
コード例 #4
0
        internal static void SceneSaved(Scene savedScene)
        {
            if (pathAndScene.ContainsKey(savedScene.path))
            {
                if (instance == null)
                {
                    instance = ScriptableObject.CreateInstance <RecentSceneData>();
                }

                var originalScene = pathAndScene.ContainsKey(savedScene.path)
                    ? pathAndScene[savedScene.path]
                    : new RecentScene(savedScene, instance);

                var scene = new RecentScene(savedScene, instance, originalScene.lastOpened, true);
                if (scene.data != null)
                {
                    var now        = System.DateTime.Now;
                    var lastEdited = $"{now.ToShortDateString()} at {now.ToShortTimeString()}";
                    var userName   = GetUserName();
                    scene.data.lastEditedBy   = userName;
                    scene.data.lastEditedDate = lastEdited;
                    scene.data.Save();
                }

                pathAndScene[savedScene.path] = scene;
            }

            if (!_newSceneNotSaved)
            {
                return;
            }

            newScene            = savedScene.path;
            _newSceneNotSaved   = false;
            _comingFromNewScene = true;
        }