This page has been translated automatically.
UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Landscape Tool
Using Editor Tools for Specific Tasks
FAQ
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
API
Containers
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
CIGI Client Plugin
Rendering-Related Classes
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

ComponentBase Class

Header:#include <UnigineComponentSystem.h>

This is a base class implementing basic functionality of logic components.

Notice
All your custom components must be inherited from this class.

See Also

ComponentBase Class

Members


static ComponentBasePtr create(const NodePtr & node, int num)

Arguments

  • const NodePtr & node
  • int num

const char * getPropertyName()

Returns the name of the property associated with the component. This method for your custom component class should look as follows:
Source code (C++)
class MyComponentClass : public ComponentBase
{
public:

	/*...*/

	// property name
	static const char* getPropertyName() { return "MyPropertyName"; }

	/*...*/
};

Return value

Property name.

void save_property(const char * name, const char * file_name)

Saves the property associated with the component to the specified file with the specified name.

Arguments

  • const char * name - Property name.
  • const char * file_name - Name of the *.prop file, to which the specified property will be saved.

void setEnabled(int enable)

Enables or disables the component.

Arguments

  • int enable - Use 1 to enable the component, 0 - to disable it.

int isEnabled()

Returns a value indicating whether the component is enabled.

Return value

1 if the component is enabled; otherwise 0.

void on_enable()

This method is called by the Engine, when the component is enabled (both, node and property are enabled). You can override this method to implement some specific actions to be performed each time, when the component is enabled.

void on_disable()

This method is called by the Engine, when the component is disabled (both, node and property are enabled). You can override this method to implement some specific actions to be performed each time, when the component is disabled.

const PropertyPtr & getProperty()

Returns the property associated with the component.

Return value

Property associated with the component.

int getPropertyNum()

Returns the number of the property associated with the component.

Return value

Number of the property in the list of properties assigned to the node.

template <C class>

C * addComponent(const NodePtr & node)

Adds the component to the specified node. This method is equivalent to ComponentSystem::addComponent() method.

Arguments

  • const NodePtr & node - Node, to which the component is to be added.

Return value

Pointer to the new added component, if it was successfully added to the specified node; otherwise nullptr.

template <C class>

int removeComponent(const NodePtr & node)

Removes the component from the specified node. This method is equivalent to ComponentSystem::removeComponent() method.

Arguments

  • const NodePtr & node - Node, from which the component is to be removed.

Return value

1 if the component was successfully removed from the specified node; otherwise 0.

template <C class>

C * getComponent(const NodePtr & node)

Returns the first component of the specified type associated with the specified node. This method is equivalent to ComponentSystem::getComponent() method.

Arguments

  • const NodePtr & node - Node, for which the component of this type is to be found.

Return value

Pointer to the component if it exists; otherwise, nullptr.

template <C class>

void getComponents(const NodePtr & node, Vector<C *> & components)

Returns all components of this type assigned to the specified node and puts them to the specified buffer vector. This method is equivalent to ComponentSystem::getComponents() method.

Arguments

  • const NodePtr & node - Node, whose components are to be retrieved.
  • Vector<C *> & components - Buffer vector, to which all found components of this type will be put.

template <C class>

C * getComponentInChildren(const NodePtr & node)

Returns the first component of this type found among all the children of the specified node (including the node itself). This method searches for the component in the following order:
  • node itself
  • node reference
  • node's children
  • children of node's children
This method is equivalent to ComponentSystem::getComponentInChildren() method.

Arguments

  • const NodePtr & node - Node, whose hierarchy is to be checked for the components of this type.

Return value

Pointer to the component if it exists; otherwise, nullptr.

template <C class>

void getComponentsInChildren(const NodePtr & node, Vector<C *> & components)

Searches for all components of this type down the hierarchy of the specified node and puts them to the given buffer vector. This method is equivalent to ComponentSystem::getComponentsInChildren() method.

Arguments

  • const NodePtr & node - Node, whose hierarchy is to be checked for the components of this type.
  • Vector<C *> & components - Buffer vector, to which all found components of this type will be put.

template <C class>

C * getComponentInParent(const NodePtr & node)

Returns the first component of this type found among all predecessors and posessors of the specified node. This method is equivalent to ComponentSystem::getComponentInParent() method.

Arguments

  • const NodePtr & node - Node, whose hierarchy is to be checked for the components of this type.

Return value

Pointer to the component if it exists; otherwise, nullptr.

template <C class>

void getComponentsInParent(const NodePtr & node, Vector<C *> & components)

Searches for all components of this type up the hierarchy of the specified node and puts them to the given buffer vector. This method is equivalent to ComponentSystem::getComponentsInParent() method.

Arguments

  • const NodePtr & node - Node, whose hierarchy is to be checked for the components of this type.
  • Vector<C *> & components - Buffer vector, to which all found components of this type will be put.

const NodePtr & getNode()

void destroyNode(const NodePtr & node)

Destroys the specified node. The node will be destroyed with all its properties and components. The node will not be deleted immediately
Notice
Make sure, that the node you're trying to delete is owned by the Editor or is an orphan (release() method was called). Anyway the node must not be owned by code, otherwise a crash will be imminent.

Arguments

  • const NodePtr & node - Node to be destroyed.

void setDestroyCallback(CallbackBase * func)

Sets a callback function to be called before destroying the component. This function can be used to implement certain actions to be performed when a component is destroyed.

Arguments

  • CallbackBase * func - Callback function.

void clearDestroyCallback()

Removes a destroy callback function previously set by the setDestroyCallback() method. This callback function can be used to implement certain actions to be performed when a component is destroyed.

void init()

Engine calls this function on world initialization. Put you code for resources initialization during the world start here.

void update()

Engine calls this function before updating each render frame. You can specify here all graphics-related functions you want to be called every frame while your application executes.

void render()

Engine calls this function before rendering each render frame. You can correct behavior after the state of the node has been updated.

void flush()

Engine calls this function before updating each physics frame. Here you can control physics and put non-rendering calculations. The engine calls flush() with the fixed rate (60 times per second by default) regardless of the fps number. Similar to the world script's flush() function.

void shutdown()

Engine calls this function on world shutdown. Here you can delete resources that were created during world script execution to avoid memory leaks.

void destroy()

Engine calls this function when the video mode is changed or application is restarted (i.e. video_restart is called). It is used to reinitialize the graphics context.
Last update: 2018-08-10
Build: ()