我试图在鼠标悬停在对象上时显示 GUI 标签,而当鼠标光标从对象上移开时标签会隐藏。
谁能告诉我为什么会出现错误?
using UnityEngine;
using System.Collections;
public class label_diet : MonoBehaviour {
public showGUI boolean = false;
void OnMouseOver()
{
showGUI = true;
}
void OnMouseExit()
{
showGUI = false;
}
void OnGUI()
{
if (showGUI)
{
GUI.Label(new Rect(10, 10, 100, 20), "You are selecting Diet coke");
}
}
}
最佳答案
更改行
public showGUI boolean = false;
到
public bool showGUI = false; //for C#
public var showGUI = false; //for JS, but you're using C#
那应该没问题;如果不是,请检查脚本是否附加到 UI 对象或具有碰撞器组件的对象。
关于c# - "The type or namespace name could not be found. Are you missing assembly reference ?"统一错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38449288/