Skip to main content
added 17 characters in body
Source Link
Notbad
  • 1.1k
  • 2
  • 19
  • 31

Just for reference I ended doing this in my game controller:

void Start()
{
    DontDestroyOnLoad(gameObject);
}

void OnEnable()
{
    SceneManager.sceneLoaded += OnSceneLoaded;
}

void OnDisable()
{
    SceneManager.sceneLoaded -= OnSceneLoaded;
}

public void MoveToNextScene(string sceneName, ExitType exitType)
{
    _lastExitType = exitType;
    SceneManager.LoadScene(sceneName, LoadSceneMode.Additive);
}



void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
    StartCoroutine(_OnSceneLoaded(scene));
}

// Update is called once per frame
IEnumerator _OnSceneLoaded(Scene scene)
{
    var asyncOperation = SceneManager.UnloadSceneAsync(0);
    yield return newwhile WaitUntil(() => !asyncOperation.isDone)
        yield return asyncOperation;
    ...
}

Thanks to @Acme Nerd Games instructions. It felt a bit hacky to me but well, it at least works and I can move to other more important subjects.

The only thing that I don't like is that I could end with both screens loaded for a litle period of time and the player could notice it. But it is easy fixable with a quick fade out effect.

Just for reference I ended doing this in my game controller:

void Start()
{
    DontDestroyOnLoad(gameObject);
}

void OnEnable()
{
    SceneManager.sceneLoaded += OnSceneLoaded;
}

void OnDisable()
{
    SceneManager.sceneLoaded -= OnSceneLoaded;
}

public void MoveToNextScene(string sceneName, ExitType exitType)
{
    _lastExitType = exitType;
    SceneManager.LoadScene(sceneName, LoadSceneMode.Additive);
}



void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
    StartCoroutine(_OnSceneLoaded(scene));
}

// Update is called once per frame
IEnumerator _OnSceneLoaded(Scene scene)
{
    var asyncOperation = SceneManager.UnloadSceneAsync(0);
    yield return new WaitUntil(() => asyncOperation.isDone)
    ...
}

Thanks to @Acme Nerd Games instructions. It felt a bit hacky to me but well, it at least works and I can move to other more important subjects.

The only thing that I don't like is that I could end with both screens loaded for a litle period of time and the player could notice it. But it is easy fixable with a quick fade out effect.

Just for reference I ended doing this in my game controller:

void Start()
{
    DontDestroyOnLoad(gameObject);
}

void OnEnable()
{
    SceneManager.sceneLoaded += OnSceneLoaded;
}

void OnDisable()
{
    SceneManager.sceneLoaded -= OnSceneLoaded;
}

public void MoveToNextScene(string sceneName, ExitType exitType)
{
    _lastExitType = exitType;
    SceneManager.LoadScene(sceneName, LoadSceneMode.Additive);
}



void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
    StartCoroutine(_OnSceneLoaded(scene));
}

// Update is called once per frame
IEnumerator _OnSceneLoaded(Scene scene)
{
    var asyncOperation = SceneManager.UnloadSceneAsync(0);
    while (!asyncOperation.isDone)
        yield return asyncOperation;
    ...
}

Thanks to @Acme Nerd Games instructions. It felt a bit hacky to me but well, it at least works and I can move to other more important subjects.

The only thing that I don't like is that I could end with both screens loaded for a litle period of time and the player could notice it. But it is easy fixable with a quick fade out effect.

Source Link
Notbad
  • 1.1k
  • 2
  • 19
  • 31

Just for reference I ended doing this in my game controller:

void Start()
{
    DontDestroyOnLoad(gameObject);
}

void OnEnable()
{
    SceneManager.sceneLoaded += OnSceneLoaded;
}

void OnDisable()
{
    SceneManager.sceneLoaded -= OnSceneLoaded;
}

public void MoveToNextScene(string sceneName, ExitType exitType)
{
    _lastExitType = exitType;
    SceneManager.LoadScene(sceneName, LoadSceneMode.Additive);
}



void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
    StartCoroutine(_OnSceneLoaded(scene));
}

// Update is called once per frame
IEnumerator _OnSceneLoaded(Scene scene)
{
    var asyncOperation = SceneManager.UnloadSceneAsync(0);
    yield return new WaitUntil(() => asyncOperation.isDone)
    ...
}

Thanks to @Acme Nerd Games instructions. It felt a bit hacky to me but well, it at least works and I can move to other more important subjects.

The only thing that I don't like is that I could end with both screens loaded for a litle period of time and the player could notice it. But it is easy fixable with a quick fade out effect.