- Home /
How do i activate lose screen
I have a lose screen that activates after you fail a level all that is fine but how do i match the game object in my hierarchy to the one in the script i tried using tags but i keep getting null reference exception i know what it means but i just can't get it to work i even tried looking up a guide by unity but all they showed me was gameobject.SetActive(false); they didnt tell me if i needed to put anything outiside of script and I'm really confused please help!
We're going to need more details in order to provide meaningful assistance with this problem. I would recommend showing us at least a few relevant lines of your script where the problem occurs (the null reference exceptions state which line the problem occurs on) and maybe a picture or two related to the problem.
For example, the picture could be of your object in the hierarchy with the tag you're searching for.
Answer by xDevily · Aug 11, 2015 at 12:39 AM
There are two simple ways to get one object into the scene:
The first one is to find the object by code (c#):
GameObject Menu = GameObject.Find("name");
NOTE: This will not find anything if the object is not active
The second one is to declare a public variable and assign its value from editor
public GameObject Menu;
If menu object is disabled then you can use
Menu.SetActive(true);
Your answer
Follow this Question
Related Questions
Can't activate my deactivated GameObjects 1 Answer
Activate / Deactivate objects onTriggerEnter / Exit 2 Answers
first tutorial to use? 1 Answer
NullReferenceException: Object reference not set to an instance of an object 2 Answers
Change SetActive(true/false) from a GameObject which is child of a different ImageTarget 1 Answer