-1

Making simple UI transition between the scenes. When press button "Play" black screen is starting Fade, then waiting 2 second to complete fade and then we load new scene. But LoadScene don't call because script don't go after Yield return new WaitForSeconds(2)

private void Awake()
{
    Init();
}

private void Init()
{
    _firstMapButton.onClick.AddListener(() =>
    {
        UIManager.Instance.ShowFadeIn();
        Debug.Log("StartFadeIn");
        StartNewMap();
        Debug.Log("EndOfListener");
    });
}

private void StartNewMap()
{
    StartCoroutine(StartNewMapCoroutine());
}

private IEnumerator StartNewMapCoroutine()
{
    Debug.Log("Coroutine has started");
    yield return new WaitForSeconds(2);
    Debug.Log("SceneLoadDemoScene");
    SceneManager.LoadScene(StaticSceneNames.DEMO_SCENE);
}

And there is logs:

  • StartFadeIn
  • CoroutineHasStarted
  • EndOfListener
2
  • If the component was disabled or destroyed, the coroutine won't work.
    – shingo
    Nov 27, 2021 at 5:11
  • @shingo yeah, the problem was that I was deleting everything from the canvas before creating a black screen
    – Rotmayer
    Nov 27, 2021 at 5:47

1 Answer 1

0

the problem was that I was deleting everything from the canvas before creating a black screen

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.