Fix scene transitions and add demoable transition between two scenes
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user