Manual

Scene Director

Code examples to perform various interactions with the Scene Director

Load Scene Async – by build index

Create a SceneLoader that loads the Scene asynchronously in the background by its index in Build Settings, then get a reference to the newly created SceneLoader

using Doozy.Engine.Progress;
using Doozy.Engine.SceneManagement;
using UnityEngine;
using UnityEngine.SceneManagement;

public class ExampleClass : MonoBehaviour
{
    public int MySceneBuildIndex;
    public LoadSceneMode MyLoadSceneMode;
    public Progressor MyProgressor;

    private void Start()
    {
        //WITHOUT a Progressor
        SceneDirector.LoadSceneAsync(MySceneBuildIndex, MyLoadSceneMode);

        //WITH a Progressor
        SceneDirector.LoadSceneAsync(MySceneBuildIndex, MyLoadSceneMode, MyProgressor);
    }
}

Load Scene Aync – by scene name

Create a SceneLoader that loads the Scene asynchronously in the background by its name in Build Settings, then returns a reference to the newly created SceneLoader

using Doozy.Engine.Progress;
using Doozy.Engine.SceneManagement;
using UnityEngine;
using UnityEngine.SceneManagement;

public class ExampleClass : MonoBehaviour
{
    public string MySceneName;
    public LoadSceneMode MyLoadSceneMode;
    public Progressor MyProgressor;

    private void Start()
    {
        //WITHOUT a Progressor
        SceneDirector.LoadSceneAsync(MySceneName, MyLoadSceneMode);

        //WITH a Progressor
        SceneDirector.LoadSceneAsync(MySceneName, MyLoadSceneMode, MyProgressor);
    }
}

Unload Scene Async – by Scene

Destroy all GameObjects associated with the given Scene and remove the Scene from the SceneManager

using Doozy.Engine.SceneManagement;
using UnityEngine;
using UnityEngine.SceneManagement;

public class ExampleClass : MonoBehaviour
{
    public Scene MyScene;

    private void Start()
    {
        SceneDirector.UnloadSceneAsync(MyScene);
    }
}

Unload Scene Async – by build index

Destroy all GameObjects associated with the given Scene and remove the Scene from the SceneManager

using Doozy.Engine.SceneManagement;
using UnityEngine;

public class ExampleClass : MonoBehaviour
{
    public int MySceneBuildIndex;

    private void Start()
    {
        SceneDirector.UnloadSceneAsync(MySceneBuildIndex);
    }
}

Unload Scene Async – by scene name

Destroy all GameObjects associated with the given Scene and remove the Scene from the SceneManager

using Doozy.Engine.SceneManagement;
using UnityEngine;

public class ExampleClass : MonoBehaviour
{
    public string MySceneName;

    private void Start()
    {
        SceneDirector.UnloadSceneAsync(MySceneName);
    }
}