.. _api_Component: Component ========= Inherited: :ref:`Object` .. _api_Component_description: 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. .. _api_Component_public: Public Methods -------------- +-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------+ | :ref:`Actor` * | :ref:`actor` () const | +-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------+ | void | :ref:`addTag` (const TString & tag) | +-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------+ | void | :ref:`addTagByHash` (uint32_t hash) | +-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------+ | :ref:`Component` * | :ref:`component` (const TString & type) | +-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------+ | void | :ref:`drawGizmos` () | +-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------+ | void | :ref:`drawGizmosSelected` () | +-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------+ | bool | :ref:`hasTag` (const TString & tag) | +-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------+ | bool | :ref:`hasTagByHash` (uint32_t hash) | +-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------+ | :ref:`Actor` * | :ref:`instantiate` (Prefab * prefab, Vector3 position, Quaternion rotation) | +-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------+ | bool | :ref:`isEnabled` () const | +-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------+ | bool | :ref:`isEnabledInHierarchy` () const | +-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------+ | void | :ref:`removeTag` (const TString & tag) | +-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------+ | void | :ref:`removeTagByHash` (uint32_t hash) | +-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------+ | :ref:`Scene` * | :ref:`scene` () const | +-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------+ | void | :ref:`setEnabled` (bool enabled) | +-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------+ | :ref:`std::vector>` & | :ref:`tags` () | +-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------+ | :ref:`TString` | :ref:`tr` (const TString & source) | +-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------+ | :ref:`Transform` * | :ref:`transform` () const | +-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------+ | :ref:`World` * | :ref:`world` () const | +-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------+ .. _api_Component_static: Static Methods -------------- None .. _api_Component_methods: Methods Description ------------------- .. _api_Component_be9623d4: :ref:`Actor` * **Component::actor** () const Returns an Actor which the Component is attached to. ---- .. _api_Component_a3ed9c81: void **Component::addTag** (:ref:`TString` & *tag*) Adds *tag* for current component. Automatically adds component to specific Scene group. ---- .. _api_Component_8f9107a4: void **Component::addTagByHash** (uint32_t *hash*) Adds a tag for current component by tag hash. Automatically adds component to specific Scene group. ---- .. _api_Component_a3d5209b: :ref:`Component` * **Component::component** (:ref:`TString` & *type*) Returns a component with *type* attached to the same Actor. If no such component with this *type* returns nullptr. ---- .. _api_Component_415ae29c: void **Component::drawGizmos** () Implement drawGizmos if you want to draw gizmos that are always drawn. ---- .. _api_Component_8cdb90e7: void **Component::drawGizmosSelected** () Implement drawGizmosSelected to draw a gizmo if the object is selected. ---- .. _api_Component_9a6c80bd: bool **Component::hasTag** (:ref:`TString` & *tag*) Returns true if component has a tag; otherwise returns false. ---- .. _api_Component_0cea84f7: bool **Component::hasTagByHash** (uint32_t *hash*) Returns true if component has a tag provided by its hash; otherwise returns false. ---- .. _api_Component_16f8947e: :ref:`Actor` * **Component::instantiate** (:ref:`Prefab` * *prefab*, :ref:`Vector3` *position*, :ref:`Quaternion` *rotation*) Clones the actor represented by *prefab* asset. This Actor will be a sibling of caller Actor and has local *position* and rotation. ---- .. _api_Component_2a8316fd: bool **Component::isEnabled** () const Returns true if the component is enabled; otherwise returns false. ---- .. _api_Component_1fda2c56: bool **Component::isEnabledInHierarchy** () const Returns false in case of one of Actors in top hierarchy or this component was disabled; otherwise returns true. ---- .. _api_Component_5e6b8f0d: void **Component::removeTag** (:ref:`TString` & *tag*) Removes *tag* for current component. Automatically removes component from specific Scene group. ---- .. _api_Component_5ea7bd9c: void **Component::removeTagByHash** (uint32_t *hash*) Removes a tag for current component by tag hash. Automatically removes component from specific Scene group. ---- .. _api_Component_03fa2ec9: :ref:`Scene` * **Component::scene** () const Returns a Scene which the Component is attached to. ---- .. _api_Component_a6de7548: 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(). ---- .. _api_Component_a561d4bc: :ref:`std::vector>` & **Component::tags** () Returns list of component tags. ---- .. _api_Component_bcd91783: :ref:`TString` **Component::tr** (:ref:`TString` & *source*) Returns a translated version of *source* text; otherwise returns *source* text if no appropriate translated string is available. ---- .. _api_Component_6729450c: :ref:`Transform` * **Component::transform** () const Returns a transform attached to this Actor. ---- .. _api_Component_d70ef142: :ref:`World` * **Component::world** () const Returns a World which the Component is attached to.