Skip to content

How to Activate or Deactivate a GameObject in Unity

To activate or deactivate a gameobject by scripting, use the SetActive function.

public class ExampleClass : MonoBehaviour

{

void Start ()

{

gameObject.SetActive(false); //GameObject is activated in hierarchy and will be deactivated when game starts.

}

}

Leave a Reply

Your email address will not be published. Required fields are marked *