Fix scene load arguments

This commit is contained in:
2022-08-14 16:49:18 -07:00
parent fd1cfa36d5
commit e1ae7deba5
10 changed files with 30 additions and 19 deletions

View File

@@ -17,21 +17,21 @@ namespace Scampz.GameJam
}
}
public void LoadScene(Scene scene, LoadSceneMode loadSceneMode)
public void LoadScene(string sceneName, LoadSceneMode loadSceneMode)
{
StartCoroutine(LoadSceneAsync(scene, loadSceneMode));
StartCoroutine(LoadSceneAsync(sceneName, loadSceneMode));
}
public void UnloadScene(Scene scene)
public void UnloadScene(string sceneName)
{
StartCoroutine(UnloadSceneAsync(scene));
StartCoroutine(UnloadSceneAsync(sceneName));
}
private IEnumerator LoadSceneAsync(Scene scene, LoadSceneMode loadSceneMode)
private IEnumerator LoadSceneAsync(string sceneName, LoadSceneMode loadSceneMode)
{
yield return null;
var loadSceneOperation = SceneManager.LoadSceneAsync(scene.name, loadSceneMode);
var loadSceneOperation = SceneManager.LoadSceneAsync(sceneName, loadSceneMode);
loadSceneOperation.allowSceneActivation = false;
while (!loadSceneOperation.isDone)
{
@@ -43,11 +43,11 @@ namespace Scampz.GameJam
yield return loadSceneOperation;
}
private IEnumerator UnloadSceneAsync(Scene scene)
private IEnumerator UnloadSceneAsync(string sceneName)
{
yield return null;
if (SceneManager.GetSceneByName(scene.name).IsValid())
SceneManager.UnloadSceneAsync(scene);
if (SceneManager.GetSceneByName(sceneName).IsValid())
SceneManager.UnloadSceneAsync(sceneName);
}
}
}