Missingmethodexception: Unityengine. Gameobject. setActive

I have added the below script to the NPC. on clicking on to the NPC the MessageBox (Panel in Canvas) should appear. But the MessageBox.setActive() part is not working. Below is the code.

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.";
    }
}

Error:

Rest of the code like changing QuestText to QuestName when clicking on NPC is working fine.

1

1 Answer

Typo, s should be capitalized, turn it into .SetActive() instead of .setActive()

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Alexander Ross

Alexander Ross

Gaming, Esports & Interactive Media Writer

Alexander Ross has covered the video game industry for a decade, writing deep dives on game design, esports tournaments, VR developments, and gaming culture.

Share this article
Twitter Facebook Pinterest