Summary

A GameObject can have many components, which are the building blocks of the game.

Properties

Active True if this Component is enabled, and all of its ancestor GameObjects are enabled
Components Access components on this component's GameObject
ComponentVersion The version of the component. Used by Sandbox.JsonUpgrader.
DebugOverlay Allows drawing of temporary debug shapes and text in the scene
Enabled <para> The enable state of this Sandbox.Component. </para><para> This doesn't tell you whether the component is actually active because its parent Sandbox.GameObject might be disabled. This merely tells you what the component wants to be. You should use Sandbox.Component.Active to determine whether the object is truly active in the scene. </para>
Flags
GameObject The GameObject this component belongs to.
Id
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.
IsValid
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.
Network
OnComponentDestroy
OnComponentDisabled
OnComponentEnabled
OnComponentFixedUpdate
OnComponentStart
OnComponentUpdate
Scene The scene this Component is in. This is a shortcut for `GameObject.Scene`.
Tags
Transform The transform of the GameObject this component belongs to. Components don't have their own transforms but they can access the transform of the GameObject they belong to. This is a shortcut for `GameObject.Transform`.
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
Deserialize
DeserializeImmediately Deserialize this component as per Sandbox.Component.Deserialize(System.Text.Json.Nodes.JsonObject) but update Sandbox.Component.GameObject and Sandbox.Component property references immediately instead of having them deferred.
Destroy Destroy this component, if it isn't already destroyed. The component will be removed from its GameObject and will stop existing. You should avoid interating with the component after calling this.
DestroyGameObject Destroy the parent GameObject. This really only exists so when you're typing Destroy you realise that calling Destroy only destroys the Component - not the whole GameObject.
EditLogobsolete Called when something on the component has been edited
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
GetOrAddComponent Add a component to this GameObject
Invoke Invoke a method in x seconds. Won't be invoked if the component is no longer active.
Reset
Serialize

Static Methods

CopyToClipboard Copy the target Sandbox.Component to the clipboard.
DispatchEdited Run the Editor.EditorEvent.ISceneEdited.ComponentEdited(Sandbox.Component,System.String) event for the given property.
DispatchPreEdited Run the Editor.EditorEvent.ISceneEdited.ComponentPreEdited(Sandbox.Component,System.String) event for the given property.
JsonRead
JsonWrite
PasteValues Paste component values from clipboard to the target Sandbox.Component.
people
Log in to reply
You can't reply if you're not logged in. That would be crazy.