c# - "The type or namespace name could not be found. Are you missing assembly reference ?"统一错误

标签 c# user-interface unity3d monodevelop

我试图在鼠标悬停在对象上时显示 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/

相关文章:

c# - 如何使用 unity3d 在圆柱体/钟摆上保持位置

c# - 使用 SqlBulkCopy 插入数据时出错

c# - 合并 ImageBrush 和 SolidColorBrush ? (作为 Canvas 的背景)

java - Java中如何计算平均点击速度?

html - 具有相同名称的多个输入

c# - Unity 作为模拟环境——在执行大计算时延迟 Update() 循环

c# - 使用 Linq MVVM 查询 ObservableCollection

c# - 损坏的 MIDI 文件输出

jquery - 使用 jQuery UI 调整 iFrame 的大小

c# - 执行简单的网络调用以在 Unity 中检索 JSON?