GameObject automatically setting itself to disabled on entering play mode

I have a GameObject which is automatically disabling itself when I enter play mode.

There is nothing, anywhere, in my code that sets the object as disabled to begin with so I shouldn’t need to be setting it active. I haven’t unchecked the object in the Inspector window and I’ve tried to force the object to be active by making a variable to store the GameObject and theVar.SetActive(true); in the Awake function, this didn’t help. I’ve also tried this.SetActive(true);

Can anyone help me out?

It sounds to me that there is an Animation setting it as disable.

Animations run after the Update() so this means they also run after the Awake() (Unity - Manual: Order of execution for event functions)… try to put theVar.SetActive(true); in the LateUpdate(). If it works that may be a confirmation of the Animation theory

If you discarded animations and your own scripts, the only other two options I can think right now are:

  • Some gameobject up the hierarchy (parent or parent of the parent) could be disabled, in which case all other childs would be disabled too. In code, this state can be identified as “activeInHierarchy”, as oposed to “activeSelf”. Fixing this would require changing your hierarchy structure or which parts of it you disable.
  • Other script you have imported is disabling your gameobject. This can be difficult to track. If you don’t have a lot of code you can search in all files for “SetActive(” and check if any instances found could be the problem. Another way to find the culprit would be to try to mess with how that script references/finds your gameobject to disable it. It could have direct reference, (in which case a copy pasted version of the object would not be afected), it could be by name, in which case changing the name of your go would suffice, it could be position in the hierarchy, try placing a copy somewhere else, it could be by tag, try changing the tags of your gameobject, it could be searching by a particular component, try removing all components and pressing play.

I updated Unity and it fixed whatever was wrong.

FishNet networking: I had the same problem with a different cause for anyone in the future. My object which had a Network Object component was being set to inactive on play. I realised it didn’t need to be there at all since the object was a local one. When I removed the Network Object component the gameObject worked, was not set to inactive on play.