Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Scene Transition goes black when i go back to the menu

Discussion in 'Animation' started by marianaloa, Nov 13, 2021.

  1. marianaloa

    marianaloa

    Joined:
    Feb 17, 2021
    Posts:
    15
    I made scenes transitions with this video
    and it works until i want to come back to the menu, because i go back but the fade in doesn't work and stays black, this is my script if anyone can help please
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.SceneManagement;
    5.  
    6. public class LevelLoader : MonoBehaviour
    7. {
    8.     public Animator transition;
    9.  
    10.     // Update is called once per frame
    11.     void Update()
    12.     {
    13.     }
    14.  
    15.     private void Start()
    16.     {
    17.         transition.SetTrigger("End");
    18.     }
    19.  
    20.     private void OnTriggerEnter2D(Collider2D collision)
    21.     {
    22.         if (collision.gameObject.CompareTag("Foto"))
    23.         {
    24.             LoadNextLevel();
    25.             Destroy(collision.gameObject);
    26.         }
    27.     }
    28.  
    29.     public void LoadNextLevel()
    30.     {
    31.         StartCoroutine(LoadLevel(SceneManager.GetActiveScene().buildIndex + 1));
    32.     }
    33.  
    34.     IEnumerator LoadLevel(int levelIndex)
    35.     {
    36.         transition.SetTrigger("Start");
    37.         yield return new WaitForSeconds(1);
    38.         SceneManager.LoadScene(levelIndex);
    39.     }
    40. }
     
  2. KalOBrien

    KalOBrien

    Unity Technologies

    Joined:
    Apr 20, 2021
    Posts:
    89
    Can you take a screen shot of your animator to see if its being called constantly making it not play? Ensure that the entry is the Fade end.

    In general we dont support questions like this as its tutorial content out of our own space. I would strongly recommend Brackeys discord server!