缺少方法异常:UnityEngine.GameObject.setActive

MissingMethodException : UnityEngine.GameObject.setActive

我已将以下脚本添加到 NPC。单击 NPC 时,应该会出现 MessageBox(Canvas 中的面板)。但是 MessageBox.setActive() 部分不起作用。下面是代码。

import UnityEngine.UI;

var TextBoxOnCheck : int = 0;
var MessageBox : GameObject;
var TextBox : GameObject;
var TextMessage : String;
var QuestBox : GameObject;
var QuestText : GameObject;
var QuestName : String;

function OnMouseDown(){
    if (TextBoxOnCheck == 0) {
        TextBoxOnCheck = 1;
        MessageBox.setActive(true);
        TextBox.GetComponent.<Text>().text = TextMessage;
        QuestName = "Active Quest: 'Recover the loot'";
        QuestText.GetComponent.<Text>().text = QuestName;
    } else {
        TextBoxOnCheck = 0;
        MessageBox.setActive(false);
        TextMessage = "Villager: Get going then.";
    }
}

错误:

其余代码(例如在单击 NPC 时将 QuestText 更改为 QuestName)工作正常。

错别字,s应该大写,把它变成.SetActive()而不是.setActive()

https://docs.unity3d.com/ScriptReference/GameObject.SetActive.html