Component

Inherited: Object

Description

The Component class is a base class for each aspect of the actor, and how it interacts with the world.

Note: This class must be a superclass only and shouldn’t be created manually.

Public Methods

Actor *

actor () const

void

addTag (const TString & tag)

void

addTagByHash (uint32_t hash)

Component *

component (const TString & type)

void

drawGizmos ()

void

drawGizmosSelected ()

bool

hasTag (const TString & tag)

bool

hasTagByHash (uint32_t hash)

Actor *

instantiate (Prefab * prefab, Vector3 position, Quaternion rotation)

bool

isEnabled () const

bool

isEnabledInHierarchy () const

void

removeTag (const TString & tag)

void

removeTagByHash (uint32_t hash)

Scene *

scene () const

void

setEnabled (bool enabled)

std::vector &

tags ()

TString

tr (const TString & source)

Transform *

transform () const

World *

world () const

Static Methods

None

Methods Description

Actor * Component::actor () const

Returns an Actor which the Component is attached to.


void Component::addTag (TString & tag)

Adds tag for current component. Automatically adds component to specific Scene group.


void Component::addTagByHash (uint32_t hash)

Adds a tag for current component by tag hash. Automatically adds component to specific Scene group.


Component * Component::component (TString & type)

Returns a component with type attached to the same Actor. If no such component with this type returns nullptr.


void Component::drawGizmos ()

Implement drawGizmos if you want to draw gizmos that are always drawn.


void Component::drawGizmosSelected ()

Implement drawGizmosSelected to draw a gizmo if the object is selected.


bool Component::hasTag (TString & tag)

Returns true if component has a tag; otherwise returns false.


bool Component::hasTagByHash (uint32_t hash)

Returns true if component has a tag provided by its hash; otherwise returns false.


Actor * Component::instantiate (Prefab * prefab, Vector3 position, Quaternion rotation)

Clones the actor represented by prefab asset. This Actor will be a sibling of caller Actor and has local position and rotation.


bool Component::isEnabled () const

Returns true if the component is enabled; otherwise returns false.


bool Component::isEnabledInHierarchy () const

Returns false in case of one of Actors in top hierarchy or this component was disabled; otherwise returns true.


void Component::removeTag (TString & tag)

Removes tag for current component. Automatically removes component from specific Scene group.


void Component::removeTagByHash (uint32_t hash)

Removes a tag for current component by tag hash. Automatically removes component from specific Scene group.


Scene * Component::scene () const

Returns a Scene which the Component is attached to.


void Component::setEnabled (bool enabled)

Sets current state of component to enabled or disabled.

Note: The disabled component will be created but not affect the Actor. For example, MeshRender component will not draw a mesh.

See also isEnabled().


std::vector & Component::tags ()

Returns list of component tags.


TString Component::tr (TString & source)

Returns a translated version of source text; otherwise returns source text if no appropriate translated string is available.


Transform * Component::transform () const

Returns a transform attached to this Actor.


World * Component::world () const

Returns a World which the Component is attached to.