【发布时间】:2016-07-11 10:49:05
【问题描述】:
我需要一些帮助,或者我认为我的脚本中遗漏了一些内容。
我创建了一个 GUI 按钮,创建了我的 c# 脚本并将其附加到“Canvas”游戏对象。
然后在我的按钮上创建了 On Click() 事件,如下图所示:
这是我的脚本:
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);
}
}
所以当我按下按钮时没有任何反应,请帮忙! 谢谢!
【问题讨论】: