Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If I create a simple object hierarchy in my scene...

--Child1 [is active]
--Child2 [is not active] can I accurately store this as a prefab? If I drag ExampleGameObject to a new prefab, then instantiate that prefab, both Child1 and Child2 will be active, which isn't what I want.

share|improve this question

Yes you can! If you uncheck the checkmark next to the name of the game object that you want disabled in the inspector. There is also a way to do it via code without checking, i think you just call the gameObject you want to be disabled and set .active to false

enter image description here

share|improve this answer
This doesn't answer my question - try my scenario, create a prefab and drag on the ExampleGameObject. When you create a new instance of the prefab, both objects will be enabled. – Matt Bond Jul 24 '12 at 18:14
Im not exactly sure if this helps any but you could try and uncheck the mesh renderer for object in the prefab. Its technically still there, just not being displayed though. – Mungoid Jul 24 '12 at 19:04
This was my 'resort to' option, it's alright in isolation, but clutters my calling code. (I have an "enable object" script, which is used often, a generic "enable x component in object" script would be either time consuming or messy) Good advice for the times it's unavoidable though! – Matt Bond Jul 25 '12 at 6:39
OnEnable() is not being called after calling .SetActive(true). Any idea? – Nasir Mahmood Aug 20 '14 at 8:18

Annoyingly, the simplest way is to attach a script to one of the prefab GameObjects that set the enabled flag manually when the object is dropped into the editor.

using UnityEngine;
using System.Collections;

#pragma strict

public class SetInactive : MonoBehaviour {


    void OnDrawGizmos()


share|improve this answer
Annoying indeed! Useful code snippet, thanks! – Matt Bond Jul 24 '12 at 18:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.