class GameObject

in global :: Sandbox

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.


public GameObject Clone( ref CloneConfig cloneConfig )

Create a unique copy of the passed in GameObject

public static GameObject Clone( string prefabPath, Transform transform, GameObject parent = null, bool startEnabled = True, string name = null )

Clone a prefab from path

public static GameObject Clone( PrefabFile prefabFile, Transform transform, GameObject parent = null, bool startEnabled = True, string name = null )

Clone a prefab from path

public GameObject Clone( Transform transform, GameObject parent = null, bool startEnabled = True, string name = null )

Create a unique copy of the GameObject

public GameObject Clone( Vector3 position )

Create a unique copy of the GameObject

public GameObject Clone( Vector3 position, Rotation rotation )

Create a unique copy of the GameObject

public GameObject Clone( Vector3 position, Rotation rotation, Vector3 scale )

Create a unique copy of the GameObject

public GameObject Clone( GameObject parent, Vector3 position, Rotation rotation, Vector3 scale )

Create a unique copy of the GameObject

public Scene Scene { get; }

The scene that this GameObject is in.

public GameTransform Transform { get; }

Our position relative to our parent, or the scene if we don't have any parent.

public string Name { get; set; }

The GameObject's name is usually used for debugging, and for finding it in the scene.

public bool IsRoot { get; }

Returns true of this is a root object. Root objects are parented to the scene.

public GameObject Root { get; }

Return the root GameObject. The root is the object that is parented to the scene - which could very much be this object.

public CancellationToken EnabledToken { get; }

This token is cancelled when the GameObject ceases to exist, or is disabled

public ComponentList Components { get; }

Access components on this GameObject

public bool Enabled { get; set; }

Is this gameobject enabled?

public bool Active { get; }

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.

public bool IsDescendant( GameObject decendant )

Returns true if the passed in object is a decendant of ours

public bool IsAncestor( GameObject ancestor )

Returns true if the passed in object is an ancestor

public GameObject GetNextSibling( bool enabledOnly )

Get the GameObject after us,

public DebugOverlaySystem DebugOverlay { get; }

Allows drawing of temporary debug shapes and text in the scene

public bool IsValid { get; }

True if the GameObject is not destroyed

public bool IsDestroyed { get; }

Return true if this object is destroyed. This will also return true if the object is marked to be destroyed soon.

public Transform LocalTransform { get; set; }

The local transform of the game object.

public Vector3 LocalPosition { get; set; }

The local position of the game object.

public Rotation LocalRotation { get; set; }

The local rotation of the game object.

public Vector3 LocalScale { get; set; }

The local scale of the game object.

public bool IsProxy { get; }

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.

public bool IsNetworkRoot { get; }

If true then this object is the root of a networked object.

public bool Networked { get; set; }

OBSOLETE: Use NetworkMode instead.

public NetworkMode NetworkMode { get; set; }

How should this object be networked to other clients? By default, a will be networked as part of the snapshot.

public bool NetworkInterpolation { get; set; }

Whether or not our networked transform will be interpolated. This property will only be synchronized for a root network object.

public bool NetworkSpawn( bool enabled, Connection owner )

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.

public bool NetworkSpawn( Connection owner )

Spawn on the network. If you have permission to spawn entities, this will spawn on everyone else's clients and the owner will be the connection provided.

public GameObject.NetworkAccessor Network { get; }

Access network information for this GameObject.

public static GameObject GetPrefab( string prefabFilePath )

Get the GameObject of a prefab from file path

public SoundHandle PlaySound( SoundEvent sound, Vector3 positionOffset = null )

Play this sound on this GameObject. The sound will follow the position of the GameObject.

public void StopAllSounds( float fadeOutTime = 0 )

Stop any sounds playing on this GameObject

public Transform WorldTransform { get; set; }

The world transform of the game object.

public Vector3 WorldPosition { get; set; }

The world position of the game object.

public Rotation WorldRotation { get; set; }

The world rotation of the game object.

public Vector3 WorldScale { get; set; }

The world scale of the game object.

public GameObject( GameObject parent, bool enabled = True, string name = null )

😔 No documentation found.

public GameObject( bool enabled, string name )

😔 No documentation found.

public int GetHashCode( )

😔 No documentation found.

public bool Equals( object obj )

😔 No documentation found.

public Type GetType( )

😔 No documentation found.

public bool NetworkSpawn( )

😔 No documentation found.

public GameTags Tags { get; set; }

😔 No documentation found.

public void BreakFromPrefab( )

😔 No documentation found.

public static object JsonRead( ref Utf8JsonReader reader, Type targetType )

😔 No documentation found.

public void SetPrefabSource( string prefabSource )

😔 No documentation found.

public static void JsonWrite( object value, Utf8JsonWriter writer )

😔 No documentation found.

public void UpdateFromPrefab( )

😔 No documentation found.

public string PrefabInstanceSource { get; }

😔 No documentation found.

public bool IsPrefabInstance { get; }

😔 No documentation found.

public bool IsPrefabInstanceRoot { get; }

😔 No documentation found.

public JsonObject Serialize( GameObject.SerializeOptions options = null )

😔 No documentation found.

public void Deserialize( JsonObject node )

😔 No documentation found.

public void Deserialize( JsonObject node, GameObject.DeserializeOptions option )

😔 No documentation found.

public GameObject( )

😔 No documentation found.

public IEnumerable<T> GetComponentsInChildren( bool includeDisabled = False, bool includeSelf = True )

😔 No documentation found.

public static GameObject Clone( string prefabPath, Nullable<CloneConfig> config = null )

😔 No documentation found.

public static GameObject Clone( PrefabFile prefabFile, Nullable<CloneConfig> config = null )

😔 No documentation found.

public GameObject Clone( )

😔 No documentation found.

public string ToString( )

😔 No documentation found.

public GameObject Parent { get; set; }

😔 No documentation found.

public List<GameObject> Children { get; }

😔 No documentation found.

public void AddSibling( GameObject go, bool before, bool keepWorldPosition = True )

😔 No documentation found.

public void SetParent( GameObject value, bool keepWorldPosition = True )

😔 No documentation found.

public void MakeNameUnique( )

😔 No documentation found.

public IEnumerable<GameObject> GetAllObjects( bool enabled )

😔 No documentation found.

public void EditLog( string name, object source )

😔 No documentation found.

public BBox GetBounds( )

😔 No documentation found.

public Guid Id { get; }

😔 No documentation found.

public BBox GetLocalBounds( )

😔 No documentation found.

public void DestroyImmediate( )

😔 No documentation found.

public void Clear( )

😔 No documentation found.

public GameObjectFlags Flags { get; set; }

😔 No documentation found.

public T AddComponent( bool startEnabled = True )

😔 No documentation found.

public T GetOrAddComponent( bool startEnabled = True )

😔 No documentation found.

public T GetComponent( bool includeDisabled = False )

😔 No documentation found.

public IEnumerable<T> GetComponents( bool includeDisabled = False )

😔 No documentation found.

public GameObject( bool enabled )

😔 No documentation found.

public T GetComponentInChildren( bool includeDisabled = False, bool includeSelf = True )

😔 No documentation found.

public IEnumerable<T> GetComponentsInParent( bool includeDisabled = False, bool includeSelf = True )

😔 No documentation found.

public T GetComponentInParent( bool includeDisabled = False, bool includeSelf = True )

😔 No documentation found.

public bool HasGimzoHandle { get; }

😔 No documentation found.

public void Destroy( )

😔 No documentation found.

public bool HasGizmoHandle { get; }

😔 No documentation found.