SceneTransitionManager - Loading Method
Posted: Wed Dec 15, 2021 6:50 pm
Hey there! I was just wondering if you might consider adding a method like this to SceneTransitionManager:
Something that could be called from SaveSystem:
Or maybe there's already a way to do this? I just realized I had started a coroutine that had the exact same while loop waiting for the loading to finish.
Code: Select all
public virtual void OnLoading(float progress) { }
Code: Select all
private static IEnumerator LoadSceneInternalTransitionCoroutine(string sceneName)
{
yield return instance.StartCoroutine(sceneTransitionManager.LeaveScene());
if (sceneName.StartsWith("index:"))
{
var index = SafeConvert.ToInt(sceneName.Substring("index:".Length));
m_currentAsyncOperation = UnityEngine.SceneManagement.SceneManager.LoadSceneAsync(index);
}
else
{
m_currentAsyncOperation = UnityEngine.SceneManagement.SceneManager.LoadSceneAsync(sceneName);
}
while (m_currentAsyncOperation != null && !m_currentAsyncOperation.isDone)
{
sceneTransitionManager.OnLoading(m_currentAsyncOperation.progress);
yield return null;
}
sceneTransitionManager.OnLoading(1f);
m_currentAsyncOperation = null;
instance.StartCoroutine(sceneTransitionManager.EnterScene());
}
Or maybe there's already a way to do this? I just realized I had started a coroutine that had the exact same while loop waiting for the loading to finish.