Legacy Documentation: Version 4.6.2
Language: English
  • C#
  • JS
  • Boo

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.


Suggest a change


Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.


Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.



public function SetActive(value: bool): void;
public void SetActive(bool value);
public def SetActive(value as bool) as void


Activates/Deactivates the GameObject.

Note that a GameObject may be inactive because a parent is not active. In that case, calling SetActive() will not activate it, but only set the local state of the GameObject, which can be checked using GameObject.activeSelf. This state will then be used once all parents are active.
Making a GameObject inactive will disable every component, turning off any attached renderers, colliders, rigidbodies, scripts, etc... Any scripts that you have attached to the GameObject will no longer have Update() called, for example.

See Also: GameObject.activeSelf, GameObject.activeInHierarchy.

	// Deactivates the game object.
	gameObject.SetActive (false);
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    void Example() {
import UnityEngine
import System.Collections

public class ExampleClass(MonoBehaviour):

	def Example() as void: