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.

Constructors

GameObject

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
HasGimzoHandleobsolete
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.
Networkedobsolete 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 Add a component to this GameObject
AddSibling
BreakFromPrefab We are cloned from a prefab. Stop that.
Clear Destroy all components and child objects
Clone Create a unique copy of the passed in 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.
EditLogobsolete
GetAllObjects
GetBounds This is slow, and somewhat innacurate. Don't call it every frame!
GetComponent Get a component on this GameObject
GetComponentInChildren Get component on this GameObject or on descendant GameObjects
GetComponentInParent Get component on this GameObject and on ancestor GameObjects
GetComponents Get components on this GameObject
GetComponentsInChildren Get components on this GameObject and on descendant GameObjects
GetComponentsInParent Get components on this GameObject and on ancestor GameObjects
GetLocalBounds This is slow, and somewhat innacurate. Don't call it every frame!
GetNextSibling Get the GameObject after us,
GetOrAddComponent Add a component to this GameObject
IsAncestor Returns true if the passed in object is an ancestor
IsDescendant Returns true if the passed in object is a decendant of ours
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 Play this sound on this GameObject. The sound will follow the position of the GameObject. You'll be able to use GameObject.StopAllSounds to stop all sounds that are following this GameObject.
Serialize Returns either a full JsonObject with all the GameObjects data, or if this GameObject is a prefab instance, it wil return an object containing the patch/diff between instance and prefab.
SetParent
SetPrefabSourceobsolete
StopAllSounds Stop any sounds playing on this GameObject
UpdateFromPrefab

Static Methods

BreakProceduralBone Stop this bone being procedural
DispatchEdited Run the Editor.EditorEvent.ISceneEdited.GameObjectEdited(Sandbox.GameObject,System.String) event for the given property.
DispatchPreEdited Run the Editor.EditorEvent.ISceneEdited.GameObjectPreEdited(Sandbox.GameObject,System.String) event for the given property.
GetPrefab Get the GameObject of a prefab from file path
IsDeletable
JsonRead
JsonWrite
PasteComponent Paste a Sandbox.Component as a new component on the target Sandbox.GameObject.
ShouldShowInHierarchy Return true if this object should be shown in the GameObject list
people
Log in to reply
You can't reply if you're not logged in. That would be crazy.