SilentSilver
SilentSilver

Reputation: 3

Reload Scene Button doesn't work on Unity 5.3 when clicked

I need some help or I think I’m missing something on my script.

I created a GUI Button, created my c# script and attached it to the “Canvas” gameobject.

Then on my button created the On Click() event as you can view it on the following image:

GUI Button

And here is my script:

using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;

public class RestartLvl : MonoBehaviour {

    void Start () {

    }

    void Update () {

    }

    void OnMouseDown() {
        ReloadCurrentScene();
    }

    public static void ReloadCurrentScene() {

            string sceneName = SceneManager.GetActiveScene().name;
            SceneManager.LoadScene(sceneName, LoadSceneMode.Single);
    }


}

So when I press the button nothing happens, please help! Thanks!

Upvotes: 0

Views: 763

Answers (1)

mgear
mgear

Reputation: 1873

You don't need to use OnMouseDown() since you are already calling the ReloadCurrentScene() in that button OnClick event.

But the onclick event target has error message, , so you'll to fix that, might work if you just re-select it from that dropdown.

Upvotes: 0

Related Questions