Start() function doesn't work properly after Application.LoadLevel

358 Views Asked by At

my start function works fine when i start a scene but after reloading it or going to another level it has some problems. When my player dies i hide some canvas elements and show "restart" and "mainMenu" buttons. but when i reload the game reset/mainMenu buttons are still shown and other elements that i had hidden when player died are still hidden ?!

    void Start () {

    Debug.Log("LOL");
    mainMenu.SetActive(false);
    reset.SetActive(false);
}

void Update()
{
    bool r = true;
    if(Player.Life <= 0 && r == true)
    {
        reset.SetActive(true);
        mainMenu.SetActive(true);
        panel.SetActive(false);

        r = false;
    }
}

UPDATE : Suddenly my problem has solved?!! i just closed and opened my project again and it works correctly ?!

0

There are 0 best solutions below