This page has been translated automatically.
Programming
Fundamentals
Setting Up Development Environment
UnigineScript
High-Level Systems
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
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.

Property Class

This class provides an interface for property manipulation: it is used to modify properties that allow you to control values and states of the logic-related parameters. When a property parameter value is modified for a single node, an instanced property is saved into the .world file, however, it contains only the modified parameter rather than the whole list of parameters.

By using functions of this class, you can, for example, implement a properties editor.

All properties are organized in property libraries. To be modified, properties should be obtained from a loaded library via the engine.properties functions. For example, if you have the following library:

Source code (XML)
<!unigine_project.prop library>
<?xml version="1.0" encoding="utf-8"?>
<properties version="2.0">
	<property name="surface_base_0" parent="surface_base">
		<parameter name="friction">1.833</parameter>
		<parameter name="restitution">0.194</parameter>
		<parameter name="occlusion">0.791</parameter>
		<parameter name="my_parameter">190</parameter>
	</property>
	<property name="surface_base_1" parent="surface_base">
		<parameter name="my_parameter">191</parameter>
	</property>
	<property name="surface_base_2" parent="surface_base">
		<parameter name="my_parameter">192</parameter>
	</property>
</properties>
You can implement a function that changes a parameter of a given property stored in this library:
Source code (UnigineScript)
// 1. Declare the required number of instances of the Property class
Property properties[];

// 2. On the application initialization, form the array of the library properties.
// It will allow for fast access to the required properties later
int init(){
	// get the library number
	int library = engine.properties.findLibrary("unigine_project/unigine_project.prop");
	for (int num = 0; num < engine.properties.getNumProperties(library); num++) {
		// get a property from the library and add it to the array of properties
		properties[num] = engine.properties.getProperty(library,num);
	}
	
	return 1;
}

// 3. Implement the function that sets the given value for the given property
void set_my_parameter(int num, int value){
	Property property = properties[num];
	property.setParameterInt(property.findParameter("my_parameter"),value);
} 

// 4. Call the implemented function when it is necessary
int update(){

	...
	set_my_parameter(num,num+100);
	...
	
	return 1;

}

Notice
You can modify only existing parameters and states of the property. To add or remove new parameters and states, you should manually edit the .prop file or use API to edit the XML file via the code.

Adding and Removing Properties

Notice
The Property class doesn't allow adding a new property to the property library.
A new property can be added to the library in one of the following ways:
  • By manual editing of the corresponding .prop file. For example, the following .prop file contains 2 properties added manually:
    Source code (XML)
    <?xml version="1.0" encoding="utf-8"?>
    <properties version="1.00">
    	<property editable="0" name="GameObjectsUnit">
    		<state name="weapon_type" type="switch" items="air,land,all_types">0</state>
    		<state name="attack" type="toggle">1</state>
    		<parameter name="damage" type="int" max="1000">1</parameter>
    		<parameter name="velocity" type="float" max="100">30</parameter>
    		<parameter name="material" type="string"/>
    	</property>
    	<property editable="1" name="GameObjectsNavy" parent="GameObjectsUnit">
    		<state name="weapon_type">2</state>
    		<parameter name="damage">120</parameter>
    		<parameter name="material">military_navy</parameter>
    		<parameter name="material_color" type="color">1.0 1.0 1.0 1.0</parameter>
    	</property>
    </properties>
  • By inheriting from the existing property via engine.properties.inheritProperty() function.
    Notice
    The inherit() function of the Property class cannot be used in this case, as it allows inheriting a new material during runtime without storing it in any property libraries.
    For example:
    Source code (UnigineScript)
    // inherit a GameObjectsUnit_0 property from the GameObjectsUnit property
    // stored in the unigine_project.prop library
    engine.properties.inheritProperty("GameObjectsUnit","unigine_project/unigine_project.prop","GameObjectsUnit_0");
    // save changes in the library if necessary
    engine.properties.save("unigine_project/unigine_project.prop");
    Notice
    By default, all parameters and states of the inherited property are the same as specified in the parent property. A child property can override some parameters of its parent or add new ones.
  • By editing the corresponding .prop file via UnigineScript: you can open an XML file, write data into it and save it.

To delete a property, you can simply call the engine.properties.removeProperty() function:

Source code (UnigineScript)
// remove the property with the given name
engine.properties.removeProperty("GameObjectsUnit_0");
// save changes in the library if necessary
engine.properties.save("unigine_project/unigine_project.prop");

Property Class

Members


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.

void setCollision(int enable)

Updates the collision option: a value indicating if the collision test is enabled for objects with the assigned property. The object will collide only if it has the collider node flag, the surface collision flag and the property collision option set at the same time.

Arguments

  • int enable - The collision option: 1 to enable the collision test, 0 to disable it.

int getCollision()

Returns the collision option: a value indicating if the collision test is enabled for objects with the assigned property. The object will collide only if it has the collider node flag, the surface collision flag and the property collision option set at the same time.

Return value

The collision option: 1 if the collision test is enabled; otherwise, 0.

Property getCompare()

Returns the parent property, parameters of which have been changed.

Return value

Parent property.

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.

void setIntersection(int enable)

Updates the intersection option: a value indicating if the intersection test is enabled for objects with the assigned property. The intersection with the object will be detected only if it has the surface intersection flag and the property intersection option set at the same time.

Arguments

  • int enable - The intersection option: 1 to enable the intersection test, 0 to disable it.

int getIntersection()

Returns the intersection option: a value indicating if the intersection test is enabled for objects with the assigned property. The intersection with the object will be detected only if it has the surface intersection flag and the property intersection option set at the same time.

Return value

The intersection option: 1 if the intersection test is enabled; otherwise, 0.

string getName()

Returns the property name.

Return value

Name of the property.

int getNumChildren()

Returns the number of children of the current property.

Return value

Number of child properties.

int getNumParameters()

Returns the number of property's parameters.

Return value

Number of property parameters.

int getNumStates()

Returns the number of property's states including states of the parent property. If the state of the current property overrides the parent property's state, the parent property's isn't taken into account.

Return value

Number of property's states including states of the parent property.

bool setParameter(int num, Variable value)

Updates the value of the given parameter.

Arguments

  • int num - The number of the target parameter .
  • Variable value - New value of the parameter.

Variable getParameter(int num)

Returns the value of the given parameter.

Arguments

  • int num - The number of the target parameter.

Return value

Value of the parameter.

void setParameterColor(int num, vec4 value)

Updates a value of the given color parameter. If the PROPERTY_PARAMETER_COLORvariable isn't set for the parameter, the color value won't be updated.

Arguments

  • int num - The number of the parameter in range from 0 to the total number of the property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).
  • vec4 value - New value for the color parameter.

vec4 getParameterColor(int num)

Returns the current color set for the given color parameter. If the PROPERTY_PARAMETER_COLORvariable isn't set for the parameter, the function will return(0,0,0,0).

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).

Return value

Color value of the color parameter. If an error occurs, (0,0,0,0) will be returned.

void setParameterDouble(int num, double value)

Updates the value of the given double parameter. If the PROPERTY_PARAMETER_DOUBLEvariable isn't set for the parameter, the value won't be updated.

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).
  • double value - New value for the double parameter.

double getParameterDouble(int num)

Returns the current value of the given double parameter. If the PROPERTY_PARAMETER_DOUBLEvariable isn't set for the parameter, the function will return0.0.

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).

Return value

Value of the douuble parameter.

double getParameterDoubleMaxValue(int num)

Returns the maximum allowed value of the given double parameter. If the PROPERTY_PARAMETER_DOUBLEvariable isn't set for the parameter, the function will return1.0.

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).

Return value

Maximum allowed value of the double parameter.

double getParameterDoubleMinValue(int num)

Returns the minimum allowed value of the given double parameter. If the PROPERTY_PARAMETER_DOUBLEvariable isn't set for the parameter, the function will return0.0.

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).

Return value

Minimum allowed value for the double parameter.

void setParameterFloat(int num, float value)

Updates the value of the given float parameter. If the PROPERTY_PARAMETER_FLOATvariable isn't set for the parameter, the value won't be updated.

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).
  • float value - New value of the float parameter.

float getParameterFloat(int num)

Returns the current value of the given float parameter. If the PROPERTY_PARAMETER_FLOATvariable isn't set for the parameter, the function will return0.0f.

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).

Return value

Value of the float parameter.

float getParameterFloatMaxValue(int num)

Returns the maximum allowed value of the given float parameter. If the PROPERTY_PARAMETER_FLOATvariable isn't set for the parameter, the function will return1.

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).

Return value

Maximum allowed value of the float parameter.

float getParameterFloatMinValue(int num)

Returns the minimum allowed value of the given float parameter. If the PROPERTY_PARAMETER_FLOATvariable isn't set for the parameter, the function will return0.

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).

Return value

Minimum allowed value of the float parameter.

int isParameterHidden(int num)

Returns a value indicating if the given parameter is hidden.

Arguments

  • int num - The number of the target parameter in range from 0 to the total number of the property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).

Return value

1 is the parameter is hidden; otherwise, 0.

void setParameterInt(int num, int value)

Updates the value of the given integer parameter. If the PROPERTY_PARAMETER_INTvariable isn't set for the parameter, the value won't be updated.

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).
  • int value - New value for the integer parameter.

int getParameterInt(int num)

Returns the current value of the given integer parameter. If the PROPERTY_PARAMETER_INTvariable isn't set for the parameter, the function will return0.

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).

Return value

Value of the integer parameter.

int getParameterIntMaxValue(int num)

Returns the maximum allowed value of the given integer parameter. If the PROPERTY_PARAMETER_INTvariable isn't set for the parameter, the function will return1.

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).

Return value

Maximum allowed value of the integer parameter.

int getParameterIntMinValue(int num)

Returns the minimum allowed value of the given integer parameter. If the PROPERTY_PARAMETER_INTvariable isn't set for the parameter, the function will return0.

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).

Return value

Minimum allowed value of the integer parameter.

void setParameterMask(int num, int value)

Updates a value of the given mask parameter. If the PROPERTY_PARAMETER_MASKvariable isn't set for the parameter, the value won't be updated.

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).
  • int value - New value for the mask parameter.

int getParameterMask(int num)

Returns the current valuer set for the given mask parameter. If the PROPERTY_PARAMETER_MASKvariable isn't set for the parameter, the function will return0.

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).

Return value

Value of the mask parameter. If an error occurs, 0 will be returned.

string getParameterName(int num)

Returns the name of the given property's parameter name.

Arguments

  • int num - The number of the target parameter in range from 0 to the total number of the property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).

Return value

Name of the parameter.

int getParameterSliderLog10(int num)

Returns a value indicating if the given slider parameter of the current property uses a logarithmic scale (with the base ten). The slider parameter is a parameter of one of the following types: PROPERTY_PARAMETER_INT, PROPERTY_PARAMETER_FLOAT, PROPERTY_PARAMETER_DOUBLE.

Arguments

  • int num - The number of the slider parameter in range from 0 to the total number of the property's parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).

Return value

1 if the parameter uses a logarithmic scale; otherwise, 0.

int getParameterSliderMaxExpand(int num)

Returns a value indicating if the maximum value of the given slider parameter can be increased. The slider parameter is a parameter of one of the following types: PROPERTY_PARAMETER_INT, PROPERTY_PARAMETER_FLOAT, PROPERTY_PARAMETER_DOUBLE.

Arguments

  • int num - The number of the slider parameter in range from 0 to the total number of the property's parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).

Return value

1 if the maximum value can be changed; otherwise, 0.

int getParameterSliderMinExpand(int num)

Returns a value indicating if the minimum value of the given slider parameter can be decreased. The slider parameter is a parameter of one of the following types: PROPERTY_PARAMETER_INT, PROPERTY_PARAMETER_FLOAT, PROPERTY_PARAMETER_DOUBLE.

Arguments

  • int num - The number of the slider parameter in range from 0 to the total number of the property's parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).

Return value

1 if the minimum value can be changed; otherwise, 0.

void setParameterString(int num, string value)

Updates the value of the given string parameter. If the PROPERTY_PARAMETER_STRINGvariable isn't set for the parameter, the value won't be updated.

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).
  • string value - New value for the string parameter.

string getParameterString(int num)

Returns the current value of the given string parameter. If the PROPERTY_PARAMETER_STRINGvariable isn't set for the parameter, the function will returnNULL.

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).

Return value

Value of the string parameter.

int getParameterStringFile(int num)

Returns a value indicating if the given string parameter has a file flag. If the PROPERTY_PARAMETER_STRINGvariable isn't set for the parameter, the function will return0. The file flag allows specifying a file for the string parameter by double-clicking the parameter value. Such flag is specified as a value of the flags attribute of the property, for example:
Source code (XML)
<properties>
	<property name="surface_base_0" type="string" flags="file"/>	
</properties>

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).

Return value

1 if the target parameter has a file flag; otherwise 0.

void setParameterSwitch(int num, int value)

Updates the value of the given switch parameter. If the PROPERTY_PARAMETER_SWITCHvariable isn't set for the parameter, the value won't be updated.

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).
  • int value - New value for the switch parameter.

int getParameterSwitch(int num)

Returns the current value of the given switch parameter. If the PROPERTY_PARAMETER_SWITCHvariable isn't set for the parameter, the function will return0.

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).

Return value

Value of the switch parameter.

string getParameterSwitchItem(int num, int item)

Returns the value of the item of the given switch parameter. If the PROPERTY_PARAMETER_SWITCHvariable isn't set for the parameter, the function will returnNULL.

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).
  • int item - The number of the item of the switch parameter.

Return value

Value of the item. If an error occurs, NULL will be returned.

int getParameterSwitchNumItems(int num)

Returns the number of items of the given switch parameter. If the PROPERTY_PARAMETER_SWITCHvariable isn't set for the parameter, the function will return0.

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).

Return value

Number of the items of the switch parameter.

void setParameterToggle(int num, int value)

Updates the value of the given toggle parameter. If the PROPERTY_PARAMETER_TOGGLEvariable isn't set for the parameter, the value won't be updated.

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).
  • int value - New value of the toggle parameter.

int getParameterToggle(int num)

Returns the current value of the given toggle parameter. If the PROPERTY_PARAMETER_TOGGLEvariable isn't set for the parameter, the function will return0.

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).

Return value

Value of the toggle parameter.

int getParameterType(int num)

Returns the type of the given parameter.

Arguments

  • int num - The number of the target parameter in range from 0 to the total number of the property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).

Return value

One of the PROPERTY_PARAMETER_*pre-defined variables; if an error occurs,-1 will be returned.

void setParameterVec3(int num, vec3 value)

Updates the value of the given vector (vec3) parameter. If the PROPERTY_PARAMETER_VEC3variable isn't set for the parameter, the value won't be updated.

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).
  • vec3 value - New value for the vector (vec3) parameter.

vec3 getParameterVec3(int num)

Returns the current value of the given vector (vec3) parameter. If the PROPERTY_PARAMETER_VEC3variable isn't set for the parameter, the function will return(0,0,0).

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).

Return value

Value of the vector (vec3) parameter.

void setParameterVec4(int num, vec4 value)

Updates the value of the given vector (vec4) parameter. If the PROPERTY_PARAMETER_VEC4variable isn't set for the parameter, the value won't be updated.

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).
  • vec4 value - New value for the vector (vec4) parameter.

vec4 getParameterVec4(int num)

Returns the current value of the given vector (vec4) parameter. If the PROPERTY_PARAMETER_VEC4variable isn't set for the parameter, the function will return(0,0,0,0).

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).

Return value

Value of the vector (vec4) parameter.

Property getParent()

Returns the parent property.

Return value

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

int isParent(string name)

Arguments

  • string name - Name of the property.

Return value

1 if the property is a parent of the current property; otherwise, 0.

void setState(variable variable)

Updates the value or the given state. Note that the state must be editable. If the current property has no states, the state of the parent property will be changed.

Arguments

  • variable variable - State to be updated. It can either be:
    • int - the number of the target state in range from 0 to the total number of the property's states (including states of its parent; if the state of the current property overrides the parent property's state, the parent property's state isn't taken into account).
    • string - the name of the target state.

getState(variable variable)

Returns the value of the given state. If the current property has no states, the state value of the parent property will be returned.

Arguments

  • variable variable - The target state. It can either be:
    • int - the number of the target state in range from 0 to the total number of the property's states (including states of its parent; if the state of the current property overrides the parent property's state, the parent property's state isn't taken into account).
    • string - the name of the target state.

Return value

Value of the state.

int isStateHidden(int num)

Returns a value indicating if the given state is hidden.

Arguments

  • int num - The number of the target state in range from 0 to the total number of the property states (including states of its parent; if the state of the current property overrides the parent property's state, the parent property's state isn't taken into account).

Return value

1 if the state is hidden; otherwise, 0.

string getStateName(int num)

Returns the name of the given state.

Arguments

  • int num - The number of the target state in range from 0 to the total number of the property states (including states of its parent; if the state of the current property overrides thethe parent property's state, the parent property's isn't taken into account).

Return value

Name of the state.

string getStateSwitchItem(int num, int item)

Returns the name of the item of the switch state. The switch state is a state for which the PROPERTY_STATE_SWITCHvariable is set.

Arguments

  • int num - The number of the target switch state in range from 0 to the total number of the property states (including states of its parent; if the state of the current property overrides the parent property's state, the parent property's state isn't taken into account).
  • int item - The number of the item of the switch state.

Return value

Name of the switch item.

int getStateSwitchNumItems(int num)

Returns the number of items of the given switch state. The switch state is a state for which the PROPERTY_STATE_SWITCHvariable is set.

Arguments

  • int num - The number of the target switch state in range from 0 to the total number of the property states (including states of its parent; if the state of the current property overrides the parent property's state, the parent property's state isn't taken into account).

Return value

Number of items of the switch state.

int getStateType(int num)

Returns the type of the given state.

Arguments

  • int num - The number of the target state in range from 0 to the total number of the property states (including states of its parent; if the state of the current property overrides the parent property's state, the parent property's state isn't taken into account).

Return value

One of the PROPERTY_STATE_*pre-defined variables; if an error occurs,-1 will be returned.

Property clone(string name)

Clones the current property.
Source code (UnigineScript)
// get a property to be cloned
Property property = engine.properties.findProperty("surface_base_0");
// clone the property
property.clone("cloned_surface_base_0");

Arguments

  • string name - Name of the new property.

Return value

Cloned property.

int findParameter(string name)

Searches for a parameter by the given name among all parameters of the current property and also among all parameters of the parent property that aren't overridden in the current property.

Arguments

  • string name - Name of the parameter.

Return value

The number of the parameter, if it is found; otherwise, -1.

int findParameter(string name, int fast_id)

Searches for a parameter by the given name among all parameters of the current property and also among all parameters of the parent property that aren't overridden in the current property. Searching by a fast identifier provides better performance.

The difference between usual searching and searching by the fast identifier is shown below. For example, you have the following .prop file:

Source code (XML)
<properties version="2.2">
    <property name="sample_property">
        <parameter name="user_parameter_1" type="float">1</parameter>
        <parameter name="user_parameter_2" type="float">2</parameter>
        <parameter name="user_parameter_3" type="float">3</parameter>
        <parameter name="user_parameter_4" type="float">4</parameter>
    </property>
</properties>
Source code (UnigineScript)
Property property = engine.properties.findProperty("sample_property");

// full parameter search
int index = property.findParameter("user_parameter_4"); // will search in all parameters
// some code
//...
// search the parameter again
index = property.findParameter("user_parameter_4"); // will search in all parameters again

// fast index parameter
int my_param_fast_id = 42;
int index = property.findParameter("user_parameter_4",my_param_fast_id); // will search in all parameters and store parameter index in fast_id cache and return it
// some code
// ...
// search the parameter again
index = property.findParameter("user_parameter_4",my_param_fast_id); // will return parameter index from fast_id cache, no search at all

Arguments

  • string name - Name of the parameter.
  • int fast_id - Parameter's fast identifier (hash of a name). The value can be in range [0;127].

Return value

The number of the parameter, if it is found; otherwise, -1.

int findState(string name, int fast_id)

Searches for a state by the given name and the fast identifier among all states of the current property and also among all states of the parent property that aren't overridden in the current property. Searching by a fast identifier provides better performance.

The difference between usual searching and searching by the fast identifier is shown below. For example, you have the following .prop file:

Source code (XML)
<properties version="2.2">
    <property name="sample_property">
		<state name="user_state_1">0</state>
		<state name="user_state_2">1</state>
		<state name="user_state_3">1</state>
		<state name="user_state_4">0</state>
    </property>
</properties>
Source code (UnigineScript)
Property property = engine.properties.findProperty("sample_property");

// full parameter search
int index = property.findState("user_state_4"); // will search in all states
// some code
//...
// search the state again
index = property.findState("user_state_4"); // will search in all states again

// fast index state
int my_state_fast_id = 42;
int index = property.findState("user_state_4",my_state_fast_id); // will search in all states and store state index in fast_id cache and return it
// some code
// ...
// search the state again
index = property.findState("user_state_4",my_state_fast_id); // will return state index from fast_id cache, no search at all

Arguments

  • string name - Name of the target state.
  • int fast_id - State's fast identifier (hash of a name). The value can be in range [0;127].

Return value

The number of the state, if it is found; otherwise, -1.

int findState(string name)

Searches for a state by the given name among all states of the current property and also among all states of the parent property that aren't overridden in the current property.

Arguments

  • string name - Name of the target state.

Return value

The number of the state, if it is found; otherwise, -1.

Property inherit(string name)

Inherits a property from the current one.

Arguments

  • string name - Name of the new property.

Return value

Inherited property.

int loadWorld(Xml xml)

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

Arguments

  • Xml xml - An instance of the Xml class in which the property data is stored.

Return value

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

int restoreState(Stream stream, int force = 0)

Restores data of the current property (all its options, states and parameters) from a binary stream.

Arguments

  • Stream stream - The stream in which the saved property data is stored.
  • int force - A value indicating if forced restoring of property data is used: 1 to enable forced saving, 0 to disable it.

Return value

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

int saveState(Stream stream, int force = 0)

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

Arguments

  • Stream stream - The stream 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.

int saveWorld(Xml xml, int force = 0)

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

Arguments

  • Xml xml - An instance of the Xml class 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.

int PROPERTY_PARAMETER_AUX

Description

Parameter of the auxiliary type.

int PROPERTY_PARAMETER_COLOR

Description

Type of the property parameter that allows specifying the material color (a vec4 value).

int PROPERTY_PARAMETER_DOUBLE

Description

Type of the property parameter that allows accepting any double value in a given range.

int PROPERTY_PARAMETER_FLOAT

Description

Type of the property parameter that allows accepting float value in a given range.

int PROPERTY_PARAMETER_INT

Description

Type of the property parameter that allows accepting any integer value in a given range.

int PROPERTY_PARAMETER_MASK

Description

Type of the property parameter that allows specifying a mask (an integer value).

int PROPERTY_PARAMETER_STRING

Description

Type of the property parameter that allows accepting any string value.

int PROPERTY_PARAMETER_SWITCH

Description

Type of the property parameter that allows specifying a set of several possible values (more than 2).

int PROPERTY_PARAMETER_TOGGLE

Description

Type of the property parameter that allows only 2 possible values.

int PROPERTY_PARAMETER_VEC3

Description

Type of the property parameter that allows accepting any vec3 value.

int PROPERTY_PARAMETER_VEC4

Description

Type of the property parameter that allows accepting any vec4 value.

int PROPERTY_STATE_AUX

Description

State of the auxiliary type.

int PROPERTY_STATE_SWITCH

Description

State in which the property can have a set of several possible values (more than 2).

int PROPERTY_STATE_TOGGLE

Description

State in which the property can have only 2 possible values.
Last update: 2017-07-03
Build: ()