Changing order in layers at runtime with a coroutine
Hi there,
I'm creating my very first video game, so I'm a noob here and maybe there's no way to do what I'm trying to, so please let me know if this is a lost cause.
well, I've created a transition for my menu, but here's the problem: at first, my menu buttons were on the top layer, and because of that, they appeared in front of the transition. I changed the order in layers to solve that, but now the transition canvas is on top of the button canvas so i can't press any button. I also tried to put the panel with the fade in the same canvas as the buttons, but same problem, the buttons are on top of the panel and you can see them while the animation is running.
Here's the code i'm talking about:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class SceneTransition : MonoBehaviour {
public Animator transition;
public Canvas canvas;
public string scene;
bool changeLayer = false;
private void Update()
{
if(changeLayer == true)
{
Debug.Log("fucking true");
canvas.sortingOrder = 0;
}
}
public void LoadScene()
{
StartCoroutine(LoadSceneCoroutine());
}
IEnumerator LoadSceneCoroutine()
{
transition.SetTrigger("FadeIn");
yield return changeLayer == true;
yield return new WaitForSeconds(1.5f);
SceneManager.LoadScene(scene);
}
}
As you can see i'm trying to use a boolean to return true when the animation is completed, but that value is never returned. How can I solve this??
Thank you!