class GameObject

book_4_sparkGenerated
code_blocksInput

Description

An object in the scene. Functionality is added using Components. A GameObject has a transform, which explains its position, rotation and scale, relative to its parent. It also has a name, and can be enabled or disabled. When disabled, the GameObject is still in the scene, but the components don't tick and are all disabled.

Members

Static Members

Member Name Summary
Clone Clone a prefab from path.
GetPrefab Get the GameObject of a prefab from file path.
JsonRead Read JSON data into a GameObject.
JsonWrite Write GameObject data to JSON.

Instance Members

Member Name Summary
Clone Create a unique copy of the GameObject.
IsDescendant Returns true if the passed in object is a descendant of ours.
IsAncestor Returns true if the passed in object is an ancestor.
AddSibling Add a sibling GameObject.
SetParent Set the parent GameObject.
MakeNameUnique Make the GameObject's name unique.
GetAllObjects Get all GameObjects, optionally filtering by enabled state.
EditLog Edit log for the GameObject (obsolete).
GetBounds This is slow, and somewhat inaccurate. Don't call it every frame!
GetLocalBounds This is slow, and somewhat inaccurate. Don't call it every frame!
GetNextSibling Get the GameObject after us.
Destroy Destroy this object. Will actually be destroyed at the start of the next frame.
DestroyImmediate Destroy this object immediately. Use with caution.
Clear Destroy all components and child objects.
AddComponent Add a component to this GameObject.
GetOrAddComponent Add a component to this GameObject if it doesn't already exist.
GetComponent Get a component on this GameObject.
GetComponents Get components on this GameObject.
GetComponentsInChildren Get components on this GameObject and on descendant GameObjects.
GetComponentInChildren Get component on this GameObject or on descendant GameObjects.
GetComponentsInParent Get components on this GameObject and on ancestor GameObjects.
GetComponentInParent Get component on this GameObject and on ancestor GameObjects.
NetworkSpawn Spawn on the network. If you have permission to spawn entities, this will spawn on everyone else's clients and you will be the owner.
SetPrefabSource Set the prefab source for this GameObject.
BreakFromPrefab We are cloned from a prefab. Stop that.
UpdateFromPrefab Update this GameObject from its prefab.
Serialize Serialize this GameObject to JSON.
Deserialize Deserialize JSON data into this GameObject.
PlaySound Play this sound on this GameObject. The sound will follow the position of the GameObject.
StopAllSounds Stop any sounds playing on this GameObject.

Properties

Property Name Summary
Scene The scene that this GameObject is in.
Transform Our position relative to our parent, or the scene if we don't have any parent.
Name The GameObject's name is usually used for debugging, and for finding it in the scene.
IsRoot Returns true if this is a root object. Root objects are parented to the scene.
Root Return the root GameObject. The root is the object that is parented to the scene - which could very much be this object.
EnabledToken This token is cancelled when the GameObject ceases to exist, or is disabled.
Components Access components on this GameObject.
Enabled Is this gameobject enabled?
Parent The parent GameObject.
Children The child GameObjects.
Active Is this gameobject active. For it to be active, it needs to be enabled, all of its ancestors need to be enabled, and it needs to be in a scene.
DebugOverlay Allows drawing of temporary debug shapes and text in the scene.
IsValid True if the GameObject is not destroyed.
IsDestroyed Return true if this object is destroyed. This will also return true if the object is marked to be destroyed soon.
Flags The flags associated with this GameObject.
HasGimzoHandle Use HasGizmoHandle (obsolete).
HasGizmoHandle Indicates if the GameObject has a gizmo handle.
Id The unique identifier for this GameObject.
LocalTransform The local transform of the game object.
LocalPosition The local position of the game object.
LocalRotation The local rotation of the game object.
LocalScale The local scale of the game object.
IsProxy True if this is a networked object and is owned by another client.
IsNetworkRoot If true then this object is the root of a networked object.
Networked OBSOLETE: Use NetworkMode instead.
NetworkMode How should this object be networked to other clients?
NetworkInterpolation Whether or not our networked transform will be interpolated.
Network Access network information for this GameObject.
PrefabInstanceSource The source of the prefab instance.
IsPrefabInstance Indicates if this GameObject is an instance of a prefab.
IsPrefabInstanceRoot Indicates if this GameObject is the root of a prefab instance.
Tags The tags associated with this GameObject.
WorldTransform The world transform of the game object.
WorldPosition The world position of the game object.
WorldRotation The world rotation of the game object.
WorldScale The world scale of the game object.