public SceneController(
     ISceneTransition transition,
     ISceneReference startScene)
 {
     _transition   = transition;
     _currentScene = startScene;
     _loadingState = LoadingState.Idle;
 }
 private static void DrawRemoveBuildSettingsButton(ISceneReference sceneReference)
 {
     using (new EditorGUI.DisabledScope(EditorBuildSettingsHelper.Contains(sceneReference.path) == false))
     {
         if (GUILayout.Button("Remove"))
         {
             EditorBuildSettingsHelper.RemoveScene(sceneReference.path);
         }
     }
 }
 private static void DrawAddBuildSettingsButton(Object sceneAsset, ISceneReference sceneReference)
 {
     using (new EditorGUI.DisabledScope(sceneAsset == null || EditorBuildSettingsHelper.Contains(sceneReference.path)))
     {
         if (GUILayout.Button("Add"))
         {
             EditorBuildSettingsHelper.AddScene(sceneReference.path);
         }
     }
 }
        public IEnumerator OnLoadScene_InvokesSceneChangedAction()
        {
            var             sceneToLoad     = _testScenes.ReloadableTestScene;
            ISceneReference loadedScene     = null;
            var             sceneController = new SceneController(_transition, _testScenes.DefaultTestScene);

            sceneController.SceneChanged += scene => loadedScene = scene;

            yield return(sceneController.LoadScene(_testScenes.ReloadableTestScene));

            Assert.AreEqual(sceneToLoad, loadedScene);
        }
        private static void DrawOpenSceneButton(ISceneReference sceneReference)
        {
            if (GUILayout.Button("Open") == false)
            {
                return;
            }

            if (EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
            {
                EditorSceneManager.OpenScene(sceneReference.path);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Shortcut to <see cref="SceneManager.LoadSceneAsync(string,UnityEngine.SceneManagement.LoadSceneMode)"/>
        /// </summary>
        public static AsyncOperation LoadAsync(this ISceneReference sceneReference, LoadSceneMode mode = LoadSceneMode.Single)
        {
            if (sceneReference == null)
            {
                throw new ArgumentNullException(nameof(sceneReference));
            }
            if (!sceneReference.IsValid)
            {
                throw new ArgumentException($"Probably scene asset reference is empty ({sceneReference}).", nameof(sceneReference));
            }

            return(SceneManager.LoadSceneAsync(sceneReference.ScenePath, mode));
        }
Exemplo n.º 7
0
        /// <summary>
        /// Shortcut to <see cref="SceneManager.LoadScene(string,UnityEngine.SceneManagement.LoadSceneMode)"/>
        /// </summary>
        public static void LoadSync(this ISceneReference sceneReference, LoadSceneMode mode = LoadSceneMode.Single)
        {
            if (sceneReference == null)
            {
                throw new ArgumentNullException(nameof(sceneReference));
            }

            if (sceneReference.IsValid)
            {
                SceneManager.LoadScene(sceneReference.ScenePath, mode);
            }
            else
            {
                throw new ArgumentException($"Unable to load scene by reference. Reference is invalid. ({sceneReference}).", nameof(sceneReference));
            }
        }
Exemplo n.º 8
0
        public IEnumerator LoadScene(ISceneReference scene)
        {
            _gameState.LoadingState.Value = GameState.LoadingStates.Loading;

            yield return(_transition.Show());

            if (scene != _gameState.CurrentScene.Value)
            {
                yield return(UnLoadScene());

                yield return(LoadScene(scene.SceneName));

                _gameState.CurrentScene.Value = scene;
            }

            yield return(_transition.Hide());

            _gameState.LoadingState.Value = GameState.LoadingStates.Idle;
            _gameEventBus.Fire(new SceneChangedEvent(scene));
        }
Exemplo n.º 9
0
        private void DrawSceneReferenceMenu(ISceneReference sceneReference, string displayName, Color color)
        {
            var scene = AssetDatabase.LoadAssetAtPath <SceneAsset>(sceneReference?.ScenePath);

            DrawSceneAssetMenu(scene, displayName, color);
        }
Exemplo n.º 10
0
 public static AsyncOperation UnloadSceneAsync(this ISceneReference self, UnloadSceneOptions options = UnloadSceneOptions.None)
 {
     return(SceneManager.UnloadSceneAsync(self.path, options));
 }
Exemplo n.º 11
0
 public static AsyncOperation LoadSceneAsync(this ISceneReference self, LoadSceneParameters parameters)
 {
     return(SceneManager.LoadSceneAsync(self.path, parameters));
 }
Exemplo n.º 12
0
 public SceneChangedEvent(ISceneReference scene)
 {
     Scene = scene;
 }
Exemplo n.º 13
0
 public void SetDefaultSceneOverride(ISceneReference sceneReference)
 {
     _defaultSceneOverride = sceneReference;
 }
Exemplo n.º 14
0
 public static void LoadScene(this ISceneReference self, LoadSceneMode mode = LoadSceneMode.Single)
 {
     SceneManager.LoadScene(self.path, mode);
 }
Exemplo n.º 15
0
 public static SceneAsset FindSceneAsset(this ISceneReference self)
 {
     return(AssetDatabase.LoadAssetAtPath <SceneAsset>(self.path));
 }
Exemplo n.º 16
0
 private void LoadScene(ISceneReference scene)
 {
     _coroutineRunner.StartCoroutine(_sceneController.LoadScene(scene));
 }
Exemplo n.º 17
0
 public static Scene LoadScene(this ISceneReference self, LoadSceneParameters parameters)
 {
     return(SceneManager.LoadScene(self.path, parameters));
 }
Exemplo n.º 18
0
 public static AsyncOperation LoadSceneAsync(this ISceneReference self, LoadSceneMode mode = LoadSceneMode.Single)
 {
     return(SceneManager.LoadSceneAsync(self.path, mode));
 }
 private static void OnSceneChanged(ISceneReference sceneReference)
 {
     Debug.Log($"Scene changed to {sceneReference.SceneName}");
 }
Exemplo n.º 20
0
 public ChangeSceneEvent(ISceneReference scene)
 {
     Scene = scene;
 }