GameObject

class GameObject : Object

Description

GameObject is a scene intractable object.

GameObject's can represent players, shapes and scenery. In more easy way, GameObject is set of components, to add for that object real functionality.

Properties

transform

Directory access to Transform of this GameObject.

scene

The scene to witch this GameObject belongs to.

tag

Tag of this GameObject.

activeInScene

GameObject active in scene state.

Inherited Properties

name

Name of this GameObject.

Constructors

GameObject

Create new GameObject and attach Transform component.

GameObject(string name)

Create new GameObject with name and Transform.

GameObject(string name, params string[] components)

Create new GameObject and attach array of components by name.

GameObject(params string[] components)

Create new GameObject and attach array of components by name.

GameObject(string name, params Type[] components)

Create new GameObject and attach array of components by type.

GameObject(params Type[] components)

Create new GameObject and attach array of components by type.

Static Methods

CreateGameObject

Create a copy of GameObject with the same components.

If you want modify object components data and that was affected on runtime scene throw script code use MonoScript.CreateGameObject(other).

CreateGameObject(PrimitiveType primitiveType)

Create a new GameObject depends on PrimitiveType.

Destroy

Immediately destroyed GameObject after OnUpdate loop is finished. If GameObject is null this method does nothing.

Compare

Compares two gameobjects.

Methods

CompareTag

Has the game object input tag?

CompareName

Has the game object input name?

Compare

Compares two components.

AddComponent

Adds new component with Type to this GameObject, and return this component.

AddComponent(string componentType)

Adds new component to this GameObject, and return this component.

HasComponent

Returns true if to this GameObject attached component of given type otherwise false.

HasComponent(string componentType)

Returns true if to this GameObject attached component of given type otherwise false. String version.

HasComponent<T>

Returns true if to this GameObject attached component of type T otherwise false. Generic version.

GetOrAddComponent

Returns component of given type from this GameObject, it component exist there will returns it, if that component not exist, will add new component of given type to this GameObject.

GetOrAddComponent(string componetType)

Returns component of given type from this GameObject, it component exist there will returns it, if that component not exist, will add new component of given type to this GameObject. String version.

GetOrAddComponent<T>

Returns component of T from this GameObject, it component exist there will returns it, if that component not exist, will add new component of given type to this GameObject. String version.

GetComponent

Returns the given component if it attached to this GameObject. This method will return the first component with this type that he found. If you want return multiple components with this type use Component.GetComponentsOf instead.

GetComponent(string componentType)

Returns the given component if it attached to this GameObject. String version.

GetComponent<T>

Returns the given component of type T if it attached to this GameObject. If component not exist then this return null instance. Generic version.

GetComponents

Returns the array with all given components in this GameObject.

TryGetComponent

Tries to retrive the component of given type from this GameObject. This method will returns true and output not-null component if it exist. If component was not found, this returns false and set output component to null.

TryGetComponent(string componentType)

Tries to retrive the component of given string type from this GameObject. This method will returns true and output not-null component if it exist. If component was not found, this returns false and set output component to null. String version.

TryGetComponent<T>

Tries to retrive the component of given type T from this GameObject. This method will returns true and output not-null component if it exist. If component was not found, this returns false and set output component to null. Generic version.

GetUUID

Returns the Unique ID of this GameObject.

SetActiveInScene

Sets the object active state in scene. If object is active that it will rendered and perform any physics behaviour on it.

SetActiveInEditor

Sets the object active state in editor. If object is active in editor it can be visualized in editor if not it will be hidden.

IsActiveInScene

Returns active scene object state.

IsActiveInEditor

Returns true of object is active in editor.

ToString

String version of GameObject.

Inherited Methods

GetObjectID

Returns the ID of current object. ID is unique only per one runtime session. Each sessions of runtime/play mode will change the ID of object. Not recommend equal object by ID if this not one runtime session.

See Also

Component, MonoScript, Transform

Last updated