我需要一些帮助,否则我想我的剧本上漏掉了什么。
我创建了一个GUI按钮,创建了我的c#脚本,并将它附加到“画布”游戏对象上。
然后,在我的按钮上创建on ()事件,因为您可以在以下图像上查看它:
桂巴顿
这是我的剧本:
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);
}
}所以当我按下按钮什么都没有发生,请帮助!谢谢!
发布于 2016-07-11 02:49:05
您不需要使用OnMouseDown(),因为您已经在该按钮OnClick事件中调用了ReloadCurrentScene()。
但是onclick事件目标有错误消息,所以您将修复它,如果您只是从下拉列表中重新选择它,则可能会工作。
https://stackoverflow.com/questions/38297510
复制相似问题