- Home /
GameObjects deactivate when Unity starts
Sinse a few days, I've had a weird problem with some of my gameobjects. Basically what happens is that whenever I close Unity and then start it again, some of my gameobject are 'deactivated'. They are gray in the Hierarchy and in the inspector. And they are invisible in the scene view and game view aswell. Although the checkbox in the inspector indicates that they are active.
To clarify, I'm not calling SetActive anywhere in my own code.
I can reactivate them by hitting the checkbox in the inspector twice (first disabling them then enabling them). But when I then close and open Unity, they are disabled again...
So my question is: Is this a (known) bug in Unity or could there be anything else that you can do in code that can cause this weird behaviour? And also, are there more people who have this problem aswell and if so, is there something I can do to stop Unity from deactivating my gameobjects (Other then adding a script that executes in edit mode and forces my gameobject to be active on startup)
Check your assets to see if the asset itself is disabled. I've had a problem like this before.
@RLin I did just now, and this is what the prefab looks like. I can't find anything unusuall about it. Futhermore, I actually have 3 of those containers filled wit these prefabs, and only one of the containers has these 'disabled' GameObjects. The others work as intended.
@abi.kr01 Well, the prefab itself wasn't empty. In case of the equals button is was a blender file. in the other case it was an actual prefab as can be seen in the image below.
(Yes this is the prefab)
Both thanks for pointing out that this has to do with the prefab, as it is indeed fixed when I do 'GameObject' --> 'Break Prefab Instance'.
However, I kinda want to use prefabs here :p Is there a reason that anyone knows of, why this is happening to these specific instances of this prefab in my scene?