This page has been translated automatically.
视频教程
界面
要领
高级
实用建议
UnigineEditor
界面概述
资产工作流程
设置和首选项
项目开发
调整节点参数
Setting Up Materials
Setting Up Properties
照明
Landscape Tool
Sandworm
使用编辑器工具执行特定任务
Extending Editor Functionality
嵌入式节点类型
Nodes
Objects
Effects
Decals
光源
Geodetics
World Objects
Sound Objects
Pathfinding Objects
Players
编程
基本原理
搭建开发环境
Usage Examples
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine Tools
GUI
双精度坐标
应用程序接口
Containers
Common Functionality
Controls-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
创建内容
Content Optimization
Materials
Art Samples
Tutorials
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

Unigine::Properties Class

Header: #include <UnigineProperties.h>

The functions below are used to control property loading and management within the project: you can get, clone, inherit, or remove any property within the project. Reparenting is supported for all non-manual and editable properties.

You can also use callbacks to handle such events.

Notice
  • This class is a singleton.
  • To modify a single property, use functions of the Property class.

Adding Callbacks#

You can add callbacks to track any changes made to any property and perform certain actions. The signature of the callback function must be as follows:

Source code (C++)
void callback_function_name(PropertyPtr property);
Here is an example of tracking property removal via callbacks:
Source code (C++)
void property_removed(PropertyPtr property)
{
	Log::message("Property \"%s\" was removed.\n", property->getName());
    // ...
}

// somewhere in the code

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

// setting our callback function on property removal
Properties::addCallback(Property::CALLBACK_REMOVED, MakeCallback(property_removed));

// removing the property named "my_prop"
Properties::removeProperty(Properties::findProperty("my_prop")->getGUID());

See Also#

  • C++ API sample located in the folder <UnigineSDK>/source/samples/Api/Systems/Properties

Properties Class

Members


int getNumProperties ( ) #

Returns the total number of properties loaded for the current project.

Return value

Total number of properties loaded.

Ptr<Property> getProperty ( int num ) #

Returns a property by its number. The returned property can be modified by using methods of the Property class.
Source code (C++)
Vector<PropertyPtr> my_properties;
for (int i = 0; i < Properties::getNumProperties(); i++) {
	my_properties.append(Properties::getProperty(i));
}

Arguments

Return value

Property smart pointer if it exists or NULL.

int isProperty ( const char * name ) #

Checks if a property with the given name exists.

Arguments

  • const char * name - Name of the property.

Return value

1 if a property with the given name exists; otherwise, 0.

int isProperty ( const UGUID & guid ) #

Checks if a property with the given GUID exists.

Arguments

Return value

1 if a property with the given GUID exists; otherwise, 0.

int isManualProperty ( const char * name ) #

Checks if a property with the given name exists.

Arguments

  • const char * name - Name of the manual property.

Return value

1 if a manual property with the given name exists; otherwise, 0.

const char * getPropertyName ( int num ) #

Returns the name of the property by its number.

Arguments

Return value

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

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

Clones the property and assigns the specified name and path to the clone.
Notice
Without a name the cloned property won't be displayed in the properties hierarchy, without a path it won't be saved when saveProperties() is called.

Arguments

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

Return value

Property smart pointer if the property with the specified GUID exists or nullptr.

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

Searches for a property with the given name. The returned property can be managed using the methods of the Property class.

Arguments

  • const char * name - Property name.

Return value

Property, if it is found (an instance of the Property class); otherwise, nullptr.

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

Searches for a manual property with the given name. The returned property can be managed using the methods of the Property class.

Arguments

  • const char * name - Manual property name.

Return value

Manual property, if it is found (an instance of the Property class); otherwise, nullptr.

Ptr<Property> findPropertyByGUID ( const UGUID & guid ) #

Searches for a property with the given GUID. The returned property can be managed using the methods of the Property class.

Arguments

Return value

Property, if it is found (an instance of the Property class); otherwise, nullptr.

Ptr<Property> findPropertyByPath ( const char * path ) #

Searches for a property with the given path. The returned property can be managed using the methods of the Property class.

Arguments

  • const char * path - Property path.

Return value

Property, if it is found (an instance of the Property class); otherwise, nullptr.

Ptr<Property> findPropertyByFileGUID ( const UGUID & guid ) #

Searches for a property with the given *.prop file GUID. The returned property can be managed using the methods of the Property class.

Arguments

Return value

Property, if it is found (an instance of the Property class); otherwise, nullptr.

Ptr<Property> loadProperty ( const char * path ) #

Loads a property from the specified *.prop file. The returned property can be managed using the methods of the Property class.

Arguments

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

Return value

Property, if it is loaded successfully (an instance of the Property class); otherwise, nullptr.

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

Inherits a property from the given property and assigns the specified name and path to the new property.
Notice
Without a name the inherited property won't be displayed in the properties hierarchy, without a path it won't be saved when saveProperties() is called.

Arguments

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

Return value

Property smart pointer if the property with the specified GUID exists or nullptr.

int removeProperty ( const UGUID & guid, int remove_file = 0, int remove_children = 1 ) #

Removes the property with the specified GUID.
Notice
A root property (the property that has no parent) or a non-editable property cannot be removed using this function.

Arguments

  • const UGUID & guid - GUID of the property to remove.
  • int remove_file - Flag indicating if the corresponding *.prop file will be deleted. Set 1 to delete the file, or 0 to keep it.
  • int remove_children - Flag indicating if all children of the property will be deleted. Set 1 to delete all children of the property, or 0 to link all children to the parent.

Return value

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

int renameProperty ( const UGUID & guid, const char * new_name ) #

Changes the name of the property with the specified GUID.
Notice
  • The name of the *.prop file is not affected.
  • This method is not available for the manual and non-editable properties.

Arguments

  • const UGUID & guid - GUID of the property to be renamed.
  • const char * new_name - New name for the property to be set.

Return value

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

int replaceProperty ( const Ptr<Property> & property, const Ptr<Property> & new_property ) #

Replaces the specified property with a new one for all nodes and surfaces. The new property that replaces the specified one must exist. For example, if you have 3 nodes with the same property, calling this method will change this property to the specified one for all these nodes.

Arguments

Return value

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

int reparentProperty ( const UGUID & guid, const UGUID & new_parent, int save_all_values = 0 ) #

Sets a new parent for the specified property. Both properties with given GUIDs must exist.
Notice
The method isn't available for the manual and non-editable properties.

Arguments

  • const UGUID & guid - GUID of the property whose parent is to be changed.
  • const UGUID & new_parent - GUID of the property to be set as a new parent.
  • int save_all_values - Flag indicating if parameter values of the specified property will be saved after reparenting.

Return value

1 if the parent for the property is changed successfully; otherwise, 0.

void reloadProperties ( ) #

Reloads all *.prop files from all data folders.
Notice
If new *.prop files are found, they will be loaded automatically. The hierarchy will be rebuilt if necessary, while keeping all overridden parameter values.

int saveProperties ( ) #

Saves all properties that can be saved to corresponding *.prop files.
Notice
This method will save only the properties that:

Return value

1 if all properties are 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 any property are made. The signature of the callback function must be as follows:
Source code (C++)
void callback_function_name(PropertyPtr property);
Here is an example of tracking property removal via callbacks:
Source code (C++)
void property_removed(PropertyPtr property)
{
	Log::message("Property \"%s\" was removed.\n", property->getName());
    // ...
}

// somewhere in the code

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

// setting our callback function on property removal
Properties::addCallback(Properties::CALLBACK_REMOVED, MakeCallback(property_removed));

// removing the property named "my_prop"
Properties::removeProperty(Properties::findProperty("my_prop")->getGUID());

Arguments

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 any 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 any property are made.

Arguments

  • CALLBACK_INDEX callback - Callback type. One of the CALLBACK_* variables.
Last update: 2021-04-29
Build: ()