Summary

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.

Properties

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.
Children
Components Access components on this GameObject
DebugOverlay Allows drawing of temporary debug shapes and text in the scene
Enabled Is this gameobject enabled?
EnabledToken This token is cancelled when the GameObject ceases to exist, or is disabled
Flags
HasGimzoHandle
HasGizmoHandle
Id
IsDestroyed Return true if this object is destroyed. This will also return true if the object is marked to be destroyed soon.
IsNetworkRoot If true then this object is the root of a networked object.
IsPrefabInstance This GameObject is part of a prefab instance.
IsPrefabInstanceRoot This GameObject is the root of a prefab instance. Returns true for regular instance roots and nested prefab instance roots.
IsProxy True if this is a networked object and is owned by another client. This means that we're not controlling this object, so shouldn't try to move it or anything.
IsRoot Returns true of this is a root object. Root objects are parented to the scene.
IsValid True if the GameObject is not destroyed
LocalPosition The local position of the game object.
LocalRotation The local rotation of the game object.
LocalScale The local scale of the game object.
LocalTransform The local transform of the game object.
Name The GameObject's name is usually used for debugging, and for finding it in the scene.
Network Access network information for this GameObject.
Networked OBSOLETE: Use NetworkMode instead.
NetworkInterpolation Whether or not our networked transform will be interpolated. This property will only be synchronized for a root network object.
NetworkMode How should this object be networked to other clients? By default, a Sandbox.GameObject will be networked as part of the Sandbox.GameObject.Scene snapshot.
Parent
PrefabInstanceSource
Root Return the root GameObject. The root is the object that is parented to the scene - which could very much be this object.
Scene The scene that this GameObject is in.
Tags
Transform Our position relative to our parent, or the scene if we don't have any parent.
WorldPosition The world position of the game object.
WorldRotation The world rotation of the game object.
WorldScale The world scale of the game object.
WorldTransform The world transform of the game object.

Methods

AddComponent
AddSibling
BreakFromPrefab We are cloned from a prefab. Stop that.
Clear Destroy all components and child objects
Clone Create a unique copy of the GameObject
Deserialize
Destroy Destroy this object. Will actually be destroyed at the start of the next frame.
DestroyImmediate Destroy this object immediately. Calling this might cause some problems if functions are expecting the object to still exist, so it's not always a good idea.
EditLog
GetAllObjects
GetBounds This is slow, and somewhat innacurate. Don't call it every frame!
GetComponent
GetComponentInChildren
GetComponentInParent
GetComponents
GetComponentsInChildren
GetComponentsInParent
GetLocalBounds This is slow, and somewhat innacurate. Don't call it every frame!
GetNextSibling
GetOrAddComponent
IsAncestor
IsDescendant
MakeNameUnique
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.
PlaySound
Serialize
SetParent
SetPrefabSource
StopAllSounds
UpdateFromPrefab

Static Methods

GetPrefab
JsonRead
JsonWrite
people
Log in to reply
You can't reply if you're not logged in. That would be crazy.