Fixed Scene Transitions
This commit is contained in:
@@ -32,6 +32,8 @@ namespace Fruitomation.Game
|
|||||||
Transition.OnCreation(canvas);
|
Transition.OnCreation(canvas);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private const float FadeMultiplier = 4f;
|
||||||
|
|
||||||
private IEnumerator StartLoadInternal(string scene)
|
private IEnumerator StartLoadInternal(string scene)
|
||||||
{
|
{
|
||||||
AsyncOperation operation = SceneManager.LoadSceneAsync(scene);
|
AsyncOperation operation = SceneManager.LoadSceneAsync(scene);
|
||||||
@@ -50,10 +52,10 @@ namespace Fruitomation.Game
|
|||||||
|
|
||||||
while (lerp < 1f)
|
while (lerp < 1f)
|
||||||
{
|
{
|
||||||
lerp += Time.unscaledDeltaTime;
|
lerp += Time.unscaledDeltaTime * FadeMultiplier;
|
||||||
Transition.LerpValue = Mathf.Clamp01(lerp);
|
Transition.LerpValue = Mathf.Clamp01(lerp);
|
||||||
|
|
||||||
yield return null; // Waits for next frame
|
yield return new WaitForEndOfFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
operation.allowSceneActivation = true;
|
operation.allowSceneActivation = true;
|
||||||
@@ -61,14 +63,17 @@ namespace Fruitomation.Game
|
|||||||
|
|
||||||
private IEnumerator EndLoadInternal()
|
private IEnumerator EndLoadInternal()
|
||||||
{
|
{
|
||||||
|
yield return new WaitForSecondsRealtime(0.2f);
|
||||||
|
Transition.GoingUp = true;
|
||||||
|
|
||||||
float lerp = 0f;
|
float lerp = 0f;
|
||||||
|
|
||||||
while (lerp < 1f)
|
while (lerp < 1f)
|
||||||
{
|
{
|
||||||
lerp += Time.unscaledDeltaTime;
|
lerp += Time.unscaledDeltaTime * FadeMultiplier;
|
||||||
Transition.LerpValue = Mathf.Clamp01(lerp);
|
Transition.LerpValue = Mathf.Clamp01(1f - lerp);
|
||||||
|
|
||||||
yield return null; // Waits for next frame
|
yield return new WaitForEndOfFrame(); // Waits for next frame
|
||||||
}
|
}
|
||||||
|
|
||||||
Time.timeScale = 1f;
|
Time.timeScale = 1f;
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ namespace Fruitomation.Game
|
|||||||
{
|
{
|
||||||
Image img = gameObject.AddComponent<Image>();
|
Image img = gameObject.AddComponent<Image>();
|
||||||
img.color = Color.black;
|
img.color = Color.black;
|
||||||
|
img.raycastTarget = true;
|
||||||
|
|
||||||
CanvasRect = canvas.GetComponent<RectTransform>();
|
CanvasRect = canvas.GetComponent<RectTransform>();
|
||||||
Rect = transform.GetComponent<RectTransform>();
|
Rect = transform.GetComponent<RectTransform>();
|
||||||
|
|||||||
Reference in New Issue
Block a user