Search Unity

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:
    3

    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. MadeFromPolygons

    MadeFromPolygons

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