0

I have a button named PauseResume with tag pResume. When I try to find the button from script with

GameObject obj = GameObject.FindGameObjectWithTag("pResume");

or

GameObject obj = GameObject.Find("PauseResume");

I get null for obj.

4
  • 1
    any chance the button is disabled at the time you do the find with tag? Commented Feb 24, 2020 at 10:40
  • Does this answer your question? Unity C# Null Reference Exception Commented Feb 24, 2020 at 10:43
  • well it either doesn't exist in the Scene, is misspelled or it is deactivated the moment your calls are done. Commented Feb 24, 2020 at 13:23
  • Could you please send the whole script and maybe add a screenshot of your hierarchy. Commented Feb 24, 2020 at 15:38

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.