【发布时间】:2013-12-04 10:19:10
【问题描述】:
我正在尝试让我的 GUI 创建更容易一些,并同时了解它。 我不想购买或使用第三方插件。
我正在尝试制作一个我可以整体使用的按钮脚本,到目前为止我已经做到了:
using UnityEngine;
using System.Collections;
[ExecuteInEditMode()]
public class SceneBTN : MonoBehaviour {
public GUIStyle myGui;
public int theHeight = 50;
public int theWidth = 200;
public float verticalPlacement = 50;
public string buttonText = "Button Text";
void OnGUI() {
Rect BTNtext = new Rect(Screen.width / 2 - (theWidth / 2), Screen.height - verticalPlacement, theWidth, theHeight);
GUI.Label(BTNtext, buttonText, myGui);
}
void OnMouseEnter() {
print("test");
}
}
当我尝试 OnMouseEnter 时,我希望在控制台中打印测试结果,但没有任何显示。
我想我错过了一些非常基本的东西,因为我在 stackoverflow 上找到了很大的帮助,所以我再次求助于你们(顺便说一句,你们很棒)。
这是一个截图:
【问题讨论】:
标签: c# button user-interface unity3d