This page has been translated automatically.
Видеоуроки
Interface
Essentials
Advanced
Подсказки и советы
Программирование на C#
Рендеринг
Принципы работы
Свойства (properties)
Компонентная Система
Рендер
Физика
Редактор UnigineEditor
Обзор интерфейса
Работа с ассетами
Настройки и предпочтения
Работа с проектами
Настройка параметров узла
Setting Up Materials
Setting Up Properties
Освещение
Landscape Tool
Sandworm
Использование инструментов редактора для конкретных задач
Extending Editor Functionality
Встроенные объекты
Nodes
Objects
Effects
Decals
Light Sources
Geodetics
World Objects
Sound Objects
Pathfinding Objects
Players
Программирование
Основы
Настройка среды разработки
Примеры использования
UnigineScript
C++
C#
Унифицированный язык шейдеров UUSL
File Formats
Rebuilding the Engine Tools
GUI
Двойная точность координат
API
Containers
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
Работа с контентом
Оптимизация контента
Материалы
Art Samples
Tutorials
Внимание! Эта версия документация УСТАРЕЛА, поскольку относится к более ранней версии SDK! Пожалуйста, переключитесь на самую актуальную документацию для последней версии SDK.
Внимание! Эта версия документации описывает устаревшую версию SDK, которая больше не поддерживается! Пожалуйста, обновитесь до последней версии SDK.

Unigine::Property Class

Header: #include <UnigineProperties.h>
Read More

Property Class

Enums

CALLBACK_INDEX#

NameDescription
CALLBACK_RELOADED = 0Property reloaded callback. This callback is fired when the property is reloaded.
CALLBACK_MOVED = 1Property moved callback. This callback is fired when the path of the property is changed.
CALLBACK_RENAMED = 2Property renamed callback. This callback is fired when the name of the property is changed.
CALLBACK_REPARENTED = 3Property reparented callback. This callback is fired when the parent of the property is changed.
CALLBACK_PARAMETER_CHANGED = 4Property parameter changed callback. This callback is fired when the value of any parameter of the property is changed or reset to default.
CALLBACK_DESTROY = 5Property destroy callback. This callback is fired when the property is destroyed.

Members


static PropertyPtr create ( ) #

Constructor. Creates a new property instance.

Ptr<Property> getChild ( int num ) #

Returns the child property of the current property.

Arguments

  • int num - The number of the target child property.

Return value

Child property.

int getID ( ) #

Returns the ID of the property.

Return value

Property ID.

UGUID getGUID ( ) #

Returns the GUID of the property.

Return value

GUID of the property.

int isBase ( ) #

Returns a value indicating if the property is a base property.

Return value

1 if the property is a base property; otherwise, 0.

void setEditable ( int editable ) #

Sets a value indicating if the property can be edited.

Arguments

  • int editable - 1 to make the property editable; 0 to make it read-only.

int isEditable ( ) #

Returns a value indicating if the property can be edited.

Return value

1 if the property is editable; otherwise, 0.

int isHidden ( ) #

Returns a value indicating if the property is hidden.

Return value

1 if the property is hidden; otherwise, 0.

int isEngine ( ) #

Returns a value indicating if the property is engine-related (i.e. required for engine operation). Such properties are stored in the core, editor and editor2 folders.

Return value

1 if the property is engine-related; otherwise, 0.

int isInternal ( ) #

Returns a value indicating if the property is an internal one.

Return value

1 if the property is internal; otherwise, 0.

int isManual ( ) #

Returns a value indicating if the property is a manual one.

Return value

1 if the property is manual; otherwise, 0.

int isHierarchyValid ( ) #

Returns a value indicating if there are no missing parents in the hierarchy of the property.

Return value

1 if there are no missing parents in the hierarchy of the property; otherwise, 0.

void setName ( const char * name ) #

Sets a new name for the property.
Notice
This method is not available for manual and non-editable properties.

Arguments

  • const char * name - Name of the property.

const char * getName ( ) #

Returns the property name.

Return value

Name of the property.
Notice
If the property is internal and has a parent, the parent's name will be returned.

int getNumChildren ( ) #

Returns the number of children of the current property.

Return value

Number of child properties.

int hasOverrides ( ) #

Returns a value indicating if the property has at least one overridden parameter.

Return value

1 if the property has at least one overridden parameter; otherwise, 0.

Ptr<Property> getParent ( ) #

Returns the parent property.

Return value

Parent property if it exists; if the current property has no parent, nullptr will be returned.

int isParent ( const char * name ) #

Returns a value indicating if the property with the given name is a parent of this property.

Suppose we have the following two manual properties in our project:

  • Source code (XML)
    <?xml version="1.0" encoding="utf-8"?>
    <property version="2.7.3" name="my_prop" parent_name="surface_base" manual="1">
    	<parameter name="my_parameter">100</parameter>
    </property>
  • Source code (XML)
    <?xml version="1.0" encoding="utf-8"?>
    <property version="2.7.3" name="my_prop_0" parent_name="my_prop" manual="1">
    	<parameter name="my_parameter1">101</parameter>
    	<parameter name="my_parameter2">101</parameter>
    </property>

The following code will return 1 as the my_prop property is the parent of the my_prop_0 property:

Source code (C++)
// get a property named my_prop_0
PropertyPtr property = Properties::findManualProperty("my_prop_0");
// perform parent check
Log::message("%d\n",property->isParent("my_prop"));

Arguments

  • const char * name - Parent property name.

Return value

1 if the property with the given name is a parent of this property; otherwise, 0.

int isParent ( const UGUID & guid ) #

Returns a value indicating if the property with the given GUID is a parent of this property.

Arguments

  • const UGUID & guid - Parent property GUID.

Return value

1 if the property with the given GUID is a parent of this property; otherwise, 0.

int setParent ( const Ptr<Property> & property, int save_all_values = 0 ) #

Sets the given property as the parent for this property and saves the parameter values of the property (if the corresponding flag is set).
Notice
The method is not available for manual and non-editable properties.

Arguments

  • const Ptr<Property> & property - Property to be set as the parent for this property.
  • int save_all_values - Flag indicating if parameter values of the property will be saved after reparenting.

Return value

1 if the given property was successfully set as the parent for this property; otherwise, 0.

void setPath ( const char * path ) #

Sets a new path for the property.

Arguments

  • const char * path - New path to the property file.

void setFileGUID ( const UGUID & fileguid ) #

Sets a new GUID for the property file.

Arguments

  • const UGUID & fileguid - New GUID for the property file.

UGUID getFileGUID ( ) #

Returns the current GUID of the property file.

Return value

GUID of the property file.

const char * getPath ( ) #

Returns a path to the property.

Return value

Path to the property.

Ptr<Property> clone ( ) #

Clones the property. The cloned property won't have a name, a path and won't be displayed in the properties hierarchy.

Return value

Cloned property smart pointer.

Ptr<Property> clone ( const char * name, const char * path ) #

Clones the property and assigns the specified name and path to the clone. The cloned property will be saved to the specified path on saveProperties() call. This method may be used, for example, to create a property missed during project's migration.

Arguments

  • const char * name - Cloned property name.
  • const char * path - Path to save the cloned property.

Return value

Cloned property smart pointer.

Ptr<Property> clone ( const char * name, const char * path, const UGUID & guid ) #

Clones the property and assigns the specified name, GUID and path to the clone. The cloned property will be saved to the specified path on saveProperties() call. This method may be used, for example, to create a property missed during project's migration.

Arguments

  • const char * name - Cloned property name.
  • const char * path - Path to save the cloned property.
  • const UGUID & guid - Cloned property GUID.

Return value

Cloned property smart pointer.

Ptr<Property> clone ( const char * name ) #

Clones the property.
Source code (UnigineScript)
// get a property to be cloned
PropertyPtr property = Properties::findProperty("surface_base_0");
// clone the property
PropertyPtr cloned = property->clone("cloned_surface_base_0");
// perform something on the cloned pointer
// ...
// delete the pointer
cloned.grab();
cloned.destroy();

Arguments

  • const char * name - Cloned property name.

Return value

Cloned property smart pointer.

Ptr<Property> inherit ( ) #

Inherits a new property from this one. The inherited property will be empty: it won't have a name, a path and won't be displayed in the properties hierarchy.

Return value

Inherited property smart pointer.

Ptr<Property> inherit ( const char * name ) #

Inherits a new property from this one and assigns the specified name to it.

Arguments

  • const char * name - Inherited property name.

Return value

Inherited property smart pointer.

Ptr<Property> inherit ( const char * name, const char * path ) #

Inherits a new property from this one and assigns the specified name and path to it. The inherited property will be saved to the specified path on saveProperties() call.

Arguments

  • const char * name - Inherited property name.
  • const char * path - Path to save the inherited property.

Return value

Inherited property smart pointer.

Ptr<Property> inherit ( const char * name, const char * path, const UGUID & guid ) #

Inherits a new property from this one and assigns the specified name, GUID and path to it. The inherited property will be saved to the specified path on saveProperties() call.

Arguments

  • const char * name - Inherited property name.
  • const char * path - Path to save the inherited property.
  • const UGUID & guid - Inherited property GUID.

Return value

Inherited property smart pointer.

int load ( ) #

Loads the property from the file specified by the setPath() function.
Notice
This function can be used to load properties created during application execution or stored outside the data directory.

Return value

1 if the property data is loaded successfully; otherwise, 0.

int load ( const char * path ) #

Loads the property from the specified *.prop file.

Arguments

  • const char * path - Path to the *.prop file to load the property data from.

Return value

1 if the property data is loaded successfully; otherwise, 0.

int loadXml ( const Ptr<Xml> & xml ) #

Loads data of the property (all its parameters) from the given instance of the Xml class.

Arguments

  • const Ptr<Xml> & xml - Xml class instance in which the property data is stored.

Return value

1 if the property data is loaded successfully; otherwise, 0.

int loadWorld ( const Ptr<Xml> & xml ) #

Loads data of the current property (all its options, states and parameters) from the given instance of the Xml class.

Arguments

  • const Ptr<Xml> & xml - Xml class instance in which the property data is stored.

Return value

1 if the property data is loaded successfully; otherwise, 0.

int reload ( ) #

Reloads the property and all its children.

Return value

1 if the property is reloaded successfully; otherwise, 0.

int canSaveInFile ( ) #

Returns a value indicating if the property can be saved to a file. For example, this function will return 0 for an internal or manual property.

Return value

1 if the property can be saved to a file; otherwise, 0.

int saveState ( const Ptr<Stream> & stream ) #

Saves data of the current property (all its parameters) into a binary stream.

Example using saveState() and restoreState() methods:

Source code (C++)
// somewhere in code

// getting a manual property named "my_prop" via the Property Manager
PropertyPtr property = Properties::findManualProperty("my_prop");
property->setParameterInt(property->findParameter("my_int_param"), 3);

// save state
Blob blob_state = new Blob();
property.SaveState(blob_state);

// change state
property->setParameterInt(property->findParameter("my_int_param"), 4);

// restore state
blob_state.SeekSet(0);	// returning the carriage to the start of the blob
propertyparam1.RestoreState(blob_state, 0);

Arguments

  • const Ptr<Stream> & stream - Stream into which the property data will be saved.

Return value

true if the property data is saved successfully; otherwise, false.

bool restoreState ( const Ptr<Stream> & stream, int restore_mode = 0 ) #

Restores the data of the property (all its parameters) from a binary stream in the specified mode.

Example using saveState() and restoreState() methods:

Source code (C++)
// somewhere in code

// getting a manual property named "my_prop" via the Property Manager
PropertyPtr property = Properties::findManualProperty("my_prop");
property->setParameterInt(property->findParameter("my_int_param"), 3);

// save state
Blob blob_state = new Blob();
property.SaveState(blob_state);

// change state
property->setParameterInt(property->findParameter("my_int_param"), 4);

// restore state
blob_state.SeekSet(0);	// returning the carriage to the start of the blob
propertyparam1.RestoreState(blob_state, 0);

Arguments

Return value

true on success; otherwise, false.

int save ( ) #

Saves the property data to the file specified by the setPath() function.
Notice
This method is not available for manual and internal properties.

Return value

1 if the property data is saved successfully; otherwise, 0.

int save ( const char * path ) #

Saves the property data to the specified *.prop file.
Notice
This method is not available for manual properties.

Arguments

  • const char * path - Path to the *.prop file to save the property data to.

Return value

1 if the property data is saved successfully; otherwise, 0.

int saveXml ( const Ptr<Xml> & xml ) #

Saves data of the property (all its parameters) to the given instance of the Xml class.
Notice
This method is not available for manual properties.

Arguments

  • const Ptr<Xml> & xml - Xml class instance into which the property data will be saved.

Return value

1 if the property data is saved successfully; otherwise, 0.

int saveWorld ( const Ptr<Xml> & xml, int force = 0 ) #

Saves data of the current property (all its parameters) into the given instance of the Xml class.

Arguments

  • const Ptr<Xml> & xml - Xml class instance into which the property data will be saved.
  • int force - A value indicating if forced saving of property data is used: 1 to enable forced saving, 0 to disable it.

Return value

1 if the property data is saved successfully; otherwise, 0.

void * addCallback ( CALLBACK_INDEX callback, Unigine::CallbackBase1< Ptr<Property> > * func ) #

Adds a callback of the specified type. Callback functions can be used to determine actions to be performed when any changes to the property are made. The signature of the callback function should be as follows:
Source code (C++)
// for all types except for the CALLBACK_PARAMETER_CHANGED
void callback_function_name(PropertyPtr property);
Here is an example of tracking property name change via callbacks:
Source code (C++)
void name_changed(PropertyPtr property)
{
	Log::message("A property has changed its name to \"%s\".\n", property->getName());
    // ...
}

// somewhere in the code

// inheriting a new property named "my_prop" from the base property "surface_base" via the Property Manager
PropertyPtr property = Properties::findManualProperty("surface_base")->inherit("my_prop");

// setting our callback function on renaming a property
property->addCallback(Property::CALLBACK_RENAMED, MakeCallback(name_changed));

// renaming the property
property->setName("new name");

Arguments

  • CALLBACK_INDEX callback - Callback type. One of the CALLBACK_* variables.
  • Unigine::CallbackBase1< Ptr<Property> > * func - Callback pointer.

Return value

ID of the last added callback of the specified type, if the callback was added successfully; otherwise, nullptr. This ID can be used to remove this callback when necessary.

void * addCallback ( CALLBACK_INDEX callback, Unigine::CallbackBase2< Ptr<Property>, int > * func ) #

Adds a callback of the specified type. Callback functions can be used to determine actions to be performed when any changes to the property are made. The signature of the callback function should be as follows:
Source code (C++)
// for the CALLBACK_PARAMETER_CHANGED type
void callback_function_name(PropertyPtr property, int parameter_num);

Arguments

  • CALLBACK_INDEX callback - Callback type. One of the CALLBACK_* variables.
  • Unigine::CallbackBase2< Ptr<Property>, int > * func - Callback pointer.

Return value

ID of the last added callback of the specified type, if the callback was added successfully; otherwise, nullptr. This ID can be used to remove this callback when necessary.

bool removeCallback ( CALLBACK_INDEX callback, void * id ) #

Removes the specified callback from the list of callbacks of the specified type. Callback functions can be used to determine actions to be performed when any changes to the property are made.

Arguments

  • CALLBACK_INDEX callback - Callback type. One of the CALLBACK_* variables.
  • void * id - Callback ID obtained when adding it.

Return value

True if the callback with the given ID was removed successfully; otherwise false.

void clearCallbacks ( CALLBACK_INDEX callback ) #

Clears all added callbacks of the specified type. Callback functions can be used to determine actions to be performed when any changes to the property are made.

Arguments

  • CALLBACK_INDEX callback - Callback type. One of the CALLBACK_* variables.

int parameterTypeByName ( const char * param_type ) #

Returns parameter type identifier by the type name specified.

Arguments

  • const char * param_type - Parameter type name.

Return value

Parameter type identifier, one of the PARAMETER_* variables.

const char * parameterNameByType ( int param_type ) #

Returns parameter type name by the type identifier specified.

Arguments

  • int param_type - Parameter type identifier, one of the PARAMETER_* variables.

Return value

Parameter type name.

Ptr<PropertyParameter> getParameterPtr ( ) #

Returns the root property parameter.

You can't iterate through all parameters of the property in a single loop, a recursive function should be used instead:

Source code (C++)
#include <functional>
std::function<void(const PropertyParameterPtr &)> recursive_func = [&, this](const PropertyParameterPtr &p)
{
	for (int i = 0; i < p->getNumChildren(); i++)
	{
		PropertyParameterPtr child = p->getChild(i);
		
		// do something... e.g. print parameter names and values
		Log::message("- %s: %s \n", child->getName(), child->getValueString().get());
		
		recursive_func(child);
	}
};

/* ... */
int AppWorldLogic::init() {
	/* ... */
	
	// getting the root parameter of the property
	PropertyParameterPtr root_parameter = property->getParameterPtr();

	// iterating through all parameters of the property
	recursive_func(root_parameter);
	
	return 1;
}

Return value

Root property parameter smart pointer.

Ptr<PropertyParameter> getParameterPtr ( const char * name ) #

Returns a property parameter by its name.

Arguments

  • const char * name - Property parameter name.

Return value

Property parameter smart pointer.
Notice
This method never returns nullptr, regardless of whether a parameter with the specified name exists or not. It only displays an error message in the console in case of a non-existing parameter. To check if such parameter really exists, use the PropertyParameter.isExist() method. For example:
Source code (C++)
// getting some property named "my_property"
PropertyPtr pProperty = Properties::findManualProperty("my_property");

// trying to get a property parameter named "some_parameter"
PropertyParameterPtr param = pProperty->getParameterPtr("some_parameter");

// checking if such parameter exists and displaying a message
if (param->isExist())
	Log::message("Specified property parameter exists!\n");
else
	Log::message("No such parameter!\n");

Ptr<PropertyParameter> getParameterPtr ( int id ) #

Returns a property parameter by its ID.

Arguments

  • int id - Property parameter ID.

Return value

Property parameter smart pointer.
Notice
This method never returns nullptr, regardless of whether a parameter with the specified ID exists or not. It only displays an error message in the console in case of a non-existing parameter. To check if such parameter really exists, use the PropertyParameter.isExist() method. For example:
Source code (C++)
// getting some property named "my_property"
PropertyPtr pProperty = Properties::findManualProperty("my_property");

// trying to get a property parameter having the ID=30
PropertyParameterPtr param = pProperty->getParameterPtr(30);

// checking if such parameter exists and displaying a message
if (param->isExist())
	Log::message("Property parameter with the specified ID exists!\n");
else
	Log::message("No such parameter!\n");

int getNumStructs ( ) #

Returns the number of structures of the property.

Return value

Number of structures of the property.

int findStruct ( const char * name ) #

Returns the number of the structure with the specified name.

Arguments

  • const char * name - Name of the structure to be found.

Return value

Number of the structure with the specified name, if it exists; otherwise, -1.

const char * getStructName ( int num ) #

Returns the name of the structure with the specified number.

Arguments

  • int num - Structure number.

Return value

Structure name, if such structure exists, otherwise nullptr.

Ptr<Node> getNode ( ) #

Last update: 09.04.2021
Build: ()