Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

fader and load scene not working as one

Discussion in '2D' started by Eddie21uk, Jul 16, 2019.

  1. Eddie21uk

    Eddie21uk

    Joined:
    May 24, 2017
    Posts:
    1

    Hi all,

    I'm currently stuck on the fader/load scene buttons. When i click on any of the buttons with (sceneFader.FadeTo ) the scenes wont load up but when i change the (SceneManager.LoadScene) the scenes do load but i only get a black screen (the fader isnt fading). Is there a way to add both lines of code togeather?



    thanks in advance.



    codes down below





    public class Gameoverbuttons : MonoBehaviour {

    //public string menuSceneName = "Menu";

    //public string continueSceneName = "LevelMenu";



    public LevelFader sceneFader;

    public void ReplayGame()

    {



    // sceneFader.FadeTo(SceneManager.GetActiveScene().name);

    //FindObjectOfType<LevelFader>().FadeTo(SceneManager.GetActiveScene().name);

    SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);



    Debug.Log("ReplayGame");

    }



    public void ContinueGame()

    {



    // sceneFader.FadeTo(continueSceneName);

    //FindObjectOfType<LevelFader>().FadeTo("LevelMenu");

    SceneManager.LoadScene("LevelMenu");

    Debug.Log("continuegame");

    }



    public void QuitMenu()

    {



    //sceneFader.FadeTo(menuSceneName);

    SceneManager.LoadScene("Menu");

    //FindObjectOfType<LevelFader>().FadeTo("Menu");

    Debug.Log("Quit");

    }



    }
     
  2. GameDevCouple_I

    GameDevCouple_I

    Joined:
    Oct 5, 2013
    Posts:
    1,738
    please edit your post to use code tags, its pretty unreadable right now and therefore difficult to help