unity3d - Unity UI 未在脚本中将可交互性设置为 true
问题描述
我以前也遇到过这个问题,现在受不了了。为什么以及如何发生这种情况?我是 C# 新手,我不知道我做错了什么。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ButtonActivate : MonoBehaviour
{
bool Test;
Button ButtonHere;
void Update()
{
Test = true;
if (Test == true)
{
ButtonHere.interactable = true;
}
}
}
解决方案
我能想到的两个可能的错误是:
Buttonhere 正在
null
或正在引用错误的游戏对象。该脚本未附加到任何东西,请尝试将其附加到按钮本身或“主摄像头”之类的东西上。
推荐阅读
- charts - Google Datastudio 多个重新分区和类型图表
- magento2 - Magento2.0 服务器要求 - 需要指导
- amp-html - AMP 中的 Brightcove 视频对接
- apache-storm - [Storm]如果其中一个失败,锚定到相同消息 id 的其他元组会发生什么?
- java - BridJ:加载 Clp.dll 时发生 LoadLibrary 错误:动态链接库 (DLL) 初始化例程失败
- oracle - varchar 立即执行
- json - 在没有反斜杠的请求中发送 JSON
- python - pyspark 中的重型有状态 UDF
- xamarin - 来自 HttpWebResponse 的流上的 xamarin IOS ReadToEnd() 不起作用
- wpf - 如何在 Visual Studio 中安装这些饼图控件?