Fix scene transitions and add demoable transition between two scenes

This commit is contained in:
2022-08-13 15:28:24 -07:00
parent 4f93893e42
commit e0a2b1a8be
11 changed files with 2185 additions and 349 deletions

View File

@@ -1,4 +1,3 @@
using System.Collections;
using UnityEngine;
using UnityEngine.SceneManagement;
@@ -14,12 +13,12 @@ namespace Scampz.GameJam
public void OnTriggerEnter(Collider collider)
{
animator.SetTrigger("FadeOut");
StartCoroutine(LoadScene(sceneIndex));
CharacterManager.Instance.LoadScene(sceneIndex, LoadSceneMode.Additive);
}
public void OnFadeComplete()
{
StartCoroutine(LoadScene(sceneIndex));
CharacterManager.Instance.LoadScene(sceneIndex, LoadSceneMode.Additive);
}
private void Awake()
@@ -29,27 +28,5 @@ namespace Scampz.GameJam
else
Singleton = this;
}
private void FadeToLevel()
{
animator.SetTrigger("FadeOut");
}
private IEnumerator LoadScene(int levelIndex)
{
yield return null;
var loadSceneOperation = SceneManager.LoadSceneAsync(levelIndex);
loadSceneOperation.allowSceneActivation = false;
while (!loadSceneOperation.isDone)
{
if (loadSceneOperation.progress >= 0.9f)
break;
}
loadSceneOperation.allowSceneActivation = true;
yield return loadSceneOperation;
}
}
}