// Function to be called to fade to another scene using the scene's name
        // Note: this only works if the scene has been added to the project's Build Settings
        public void FadeToScene(string sceneName)
        {
            // Create a new TempFader GameObject, which will take care of the fade animation and then destroy itself.
            TempFader tempFader = TempFader.CreateTempFader(fadeColor, duration, delay);

            if (tempFader != null)
            {
                StartCoroutine(tempFader.FadeToSceneCR(() => { SceneManager.LoadScene(sceneName); }));
            }
        }
Esempio n. 2
0
 void Start()
 {
     // If this is the main FadeInOnStart component, start the fade in
     if (this == instance)
     {
         // Create a new TempFader GameObject, which will take care of the fade animation and then destroy itself
         TempFader tempFader = TempFader.CreateTempFader(fadeColor, duration, delay);
         if (tempFader != null)
         {
             StartCoroutine(tempFader.FadeInCurrentSceneCR());
         }
     }
 }