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: enter image description here

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

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like