> For the complete documentation index, see [llms.txt](https://pahutyakv.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://pahutyakv.gitbook.io/docs/mega-extension-pack/gameobject.md).

# GameObject

#### **Name**

* `Rename(string name)` — Renames this GameObject.

***

#### **Active**

* `SetActiveRecursive(bool state)` — Sets the active state of this GameObject and all its children recursively.
* `ToggleActive()` — Toggles the active state of this GameObject.
* `ToggleActiveRecursive()` — Toggles the active state of this GameObject and all its children recursively.
* `ToggleChildrenActive()` — Toggles the active state of all direct children of this GameObject.

***

#### **Layer**

* `SetLayer(int layer)` — Sets the layer of this GameObject by index.
* `SetLayer(string layer)` — Sets the layer of this GameObject by layer name.
* `SetLayerRecursive(int layer)` — Recursively sets the layer of this GameObject and all its children by index.
* `SetLayerRecursive(string layer)` — Recursively sets the layer of this GameObject and all its children by layer name.
* `CopyLayerFrom(GameObject other)` — Copies the layer from another GameObject to this GameObject.
* `IsInLayer(int layer)` — Checks if this GameObject is in the specified layer by index.
* `IsInLayer(string layer)` — Checks if this GameObject is in the specified layer by name.

***

#### **Tag**

* `SetTag(string tag)` — Sets the tag of this GameObject.
* `IsTagged(string tag)` — Checks if this GameObject has the specified tag.
* `CopyTagFrom(GameObject other)` — Copies the tag from another GameObject to this GameObject.

***

#### **Get Components**

* `GetOrAddComponent<T>() where T : Component` — Gets the component of type T if it exists on this GameObject; otherwise, adds it.
* `GetOrAddComponentInChildren<T>(bool includeInactive = true) where T : Component` — Gets or adds a component of type T on all direct children of this GameObject.
* `GetOrAddComponentInParent<T>(bool includeInactive = true) where T : Component` — Gets or adds a component of type T on all parent objects of this GameObject.

***

#### **Has Components**

* `HasComponent<T>() where T : Component` — Checks if this GameObject has a component of type T.
* `HasComponentInChildren<T>() where T : Component` — Checks if any child of this GameObject has a component of type T.
* `HasComponentInParent<T>() where T : Component` — Checks if any parent of this GameObject has a component of type T.

***

#### **Remove Components**

* `RemoveComponent<T>() where T : Component` — Removes the first component of type T from this GameObject, if it exists.
* `RemoveComponents<T>() where T : Component` — Removes all components of type T from this GameObject.
* `RemoveComponentsInChildren<T>(bool includeInactive = true) where T : Component` — Removes all components of type T from the children of this GameObject.
* `RemoveComponentsInParent<T>(bool includeInactive = true) where T : Component` — Removes all components of type T from the parents of this GameObject.

***

#### **Destroy / DontDestroy / Clone**

* `Destroy()` — Destroys the specified GameObject.
* `Destroy(float delay)` — Destroys the specified GameObject after a delay in seconds.
* `DestroyImmediate()` — Immediately destroys the specified GameObject. Use with caution.
* `DestroyChildren()` — Destroys all direct children of this GameObject after the current frame.
* `DestroyImmediateChildren()` — Immediately destroys all direct children of this GameObject.
* `DontDestroyOnLoad()` — Marks the GameObject to not be destroyed automatically when loading a new scene.
* `Clone()` — Clones this GameObject at the same position and rotation as the original.
* `CloneAt(Vector3 position)` — Clones this GameObject at the specified position with default rotation.
* `CloneAt(Vector3 position, Quaternion rotation)` — Clones this GameObject at the specified position with the specified rotation.

***

#### **Utility**

* `IsChildOf(GameObject parent)` — Checks if this GameObject is a child of the specified parent GameObject.
