This page has been translated automatically.
视频教程
界面
要领
高级
实用建议
基础
专业(SIM)
UnigineEditor
界面概述
资源工作流程
Version Control
设置和首选项
项目开发
调整节点参数
Setting Up Materials
设置属性
照明
Sandworm
使用编辑器工具执行特定任务
如何擴展編輯器功能
嵌入式节点类型
Nodes
Objects
Effects
Decals
光源
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
编程
基本原理
搭建开发环境
使用范例
C++
C#
UnigineScript
统一的Unigine着色器语言 UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
材质和着色器
Rebuilding the Engine Tools
GUI
双精度坐标
应用程序接口
Animations-Related Classes
Containers
Common Functionality
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
VR-Related Classes
创建内容
内容优化
材质
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

层次结构和继承

Properties in UNIGINE can form a hierarchy. However, there are certain rules and constraints described below, that must be taken into account.UNIGINE中的属性可以形成层次结构。但是,必须考虑以下某些规则和约束。

Properties Hierarchy
属性层次结构#

Properties hierarchy is formed by inheriting one property from another. A parent property passes all its parameters to its children so that they can be overridden, much like in object-oriented programming.属性层次结构是通过从另一个属性继承一个属性而形成的。父属性将其所有参数传递给其子对象,以便可以覆盖它们,就像在面向对象的编程中一样。

注意
All inherited and non-overridden parameters will be updated automatically, if they are updated in the parent property.如果在父属性中更新了所有继承的和非重写的参数,则它们将自动更新。

At the top of the hierarchy there are base properties. Unigine provides 2 built-in read-only base properties: node_base and surface_base. You can also make custom base properties of your own.在层次结构的顶部,有 基本属性 。 Unigine提供了2内置的只读基本属性:node_basesurface_base。您还可以创建自己的自定义基本属性。

注意
If you need to assign a property to a single surface, it is recommended to inherit it from the surface_base property.
It is also recommended to inherit properties that will be assigned to nodes from the node_base property. However, you can also assign any custom base property or its children to a node.
如果需要将属性分配给单个表面,建议从 surface_base 属性继承。
建议从node_base属性继承将分配给节点的属性。 但是,您也可以将任何自定义基本属性或其子级分配给节点。

Base properties cannot have a parent: no base property can be inherited from another base property. The values of parameters of manual properties (including base ones) cannot be changed. So, to modify parameters of a manual property via the UnigineEditor, you should inherit a user property from it. 基础属性不能具有父级:不能从其他基础属性继承基础属性。 手动属性 (包括基本属性)的参数值无法更改。因此,要通过UnigineEditor修改手动属性的参数,您应该从中继承 用户属性

The parent of a user property can be changed by dragging it to a new parent in the Properties Hierarchy window.可以通过将用户属性的父级拖动到Properties Hierarchy窗口中的新父级来进行更改。

Taking all abovementioned into account, there are the following reasons to create properties hierarchy:考虑到上述所有因素,创建属性层次结构的原因如下:

  • Inheriting from a base property allows editing its parameters via the UnigineEditor.从基本属性继承可以通过UnigineEditor编辑其参数。
  • Inheriting from a user property allows for mass controlling values of multiple property parameters.从用户属性继承可以批量控制多个属性参数的值。

Hierarchy of properties属性层次结构

Properties Loading Order
属性加载顺序#

Properties hierarchy doesn't affect the loading order of properties.属性层次结构不会影响属性的加载顺序。

Referring to Properties by GUIDs
通过GUID引用属性#

A GUID (Globally Unique Identifier) is an identifier for a property. It represents a 40-character hexadecimal string generated using the SHA-1 hash algorithm. GUID (全局唯一标识符)是属性的标识符。它表示使用SHA-1哈希算法生成的40个字符的十六进制字符串。

Properties hierarchy is based on GUIDs: all properties are referred to using GUIDs, even base and manual ones (the GUIDs for such properties are generated at run time and are uniquely determined by their names). However, only user properties store their GUIDs explicitly: a GUID is generated automatically on user property creation and is written to the corresponding *.prop file.属性层次结构基于GUID:所有属性都使用GUID引用,甚至 base manual 都一样(此类属性的GUID在运行时生成,并由他们的名字)。但是,只有用户属性会明确存储其GUID:在用户属性创建时会自动生成一个GUID,并将其写入相应的*.prop文件。

注意
Each user property created via the UnigineEditor has a GUID.通过UnigineEditor创建的每个用户属性都有一个GUID。

For example:例如:

源代码 (XML)
<property version="2.13.0.1" name="surface_base_0" guid="2750c68c5a8d5e01198c9a32ba6ffaa46ae31b8c" parent="d99ebc8ef5769d70b1e46992309cc3e7d1aa2faa"/>

The GUID of a user property is stored in the guid attribute. If user property is inherited from another user property, it will refer to the parent by its GUID (see the parent attribute in the example above).用户属性的GUID存储在guid属性中。如果用户属性是从另一个用户属性继承的,则它将通过其GUID引用父级(请参见上面示例中的parent属性)。

Using GUIDs makes it difficult to edit user properties manually. For example, to rename such property, it is required to generate a GUID for the new name and replace the current GUID.使用GUID使手动编辑用户属性变得困难。例如,要重命名该属性,需要为新名称生成一个GUID并替换当前的GUID。

As GUIDs for manual properties (including base ones) are uniquely determined by their names, changing the name of such property will also change its GUID. That is why manual properties cannot be renamed at run time. For the same reason, *.prop files of such properties store only their names, not GUIDs. Manual properties usually use name-based references to other manual properties (including base ones).因为手动属性(包括基本属性)的GUID由它们的名称唯一地确定,所以更改此类属性的名称也会更改其GUID。这就是为什么无法在运行时重命名手动属性的原因。出于相同的原因,具有此类属性的*.prop文件仅存储其名称,而不存储GUID。手动属性通常使用基于名称的引用其他手动属性(包括基本属性)。

注意
If you rename a manual property, that has other manual or user properties inherited from it, the hierarchy will be broken, and you will have to restore it manually for all children (i.e. specify new parent GUID in the parent attribute, or new parent name parent_name attribute for a manual child property).如果重命名一个手动属性,该属性继承了其他手动或用户属性,则层次结构将被破坏,并且必须为所有子级手动还原它(即在parent属性中指定新的父GUID或新的父名称)手动子属性的parent_name属性)。

Types of Inheritance
继承类型#

As it was mentioned above, base properties, which are all manual, are always at the top of the hierarchy, while other properties are inherited from them. You can inherit:如上所述,基本属性都是手动的,始终位于层次结构的顶部,而其他属性是从它们继承的。您可以继承:

  • a new user property from any other property via the UnigineEditor. 通过UnigineEditor从任何其他属性创建新的用户属性。
  • a new manual property from another manual property (including base one) by creating a new *.prop file with a name-based reference to the parent.通过创建一个新的 *.prop文件并使用基于父项的基于名称的引用来从另一个手动属性(包括基础属性)创建一个新的手动属性。

So, basically we can have the following types of inheritance:因此,基本上,我们可以具有以下类型的继承:

  • Manual Parent - Manual Child父级人工-子级人工
  • Manual Parent - User Child手动父级-用户子级
  • User Parent - User Child用户父母-使用孩子

Thus, depending on the type of inheritance, the *.prop file of a child property will store a reference to its parent as follows:因此,根据继承的类型,子属性的*.prop文件将存储对其父项的引用,如下所示:

  • Parent: manual property (including base ones).
    • If the inherited property is also manual, the corresponding *.prop file stores the name of the property, and the name of its parent in the parent_name attribute.
      注意
      Only manual properties can refer to their parent manual property by name.Only manual properties can refer to their parent manual property by name.
      源代码 (XML)
      <property version="2.13.0.1" name="my_node_base1" parent_name="node_base" manual="1"/>
      Only manual properties can refer to their parent manual property by name.
      If the inherited property is also manual, the corresponding *.prop file stores the name of the property, and the name of its parent in the parent_name attribute.
      注意
      Only manual properties can refer to their parent manual property by name.Only manual properties can refer to their parent manual property by name.
      源代码 (XML)
      <property version="2.13.0.1" name="my_node_base1" parent_name="node_base" manual="1"/>
    • If the inherited property is not manual (i.e it is a user property), the corresponding *.prop file stores a GUID of the user property, and the GUID of its parent (generated at run time from the parent's name) in the parent attribute.
      源代码 (XML)
      <property version="2.13.0.1" name="my_node_base2" guid="cccd50e4431ddaeaf01dcb394fc988def578b380" parent="d99ebc8ef5769d70b1e46992309cc3e7d1aa2faa"/>
      If the inherited property is not manual (i.e it is a user property), the corresponding *.prop file stores a GUID of the user property, and the GUID of its parent (generated at run time from the parent's name) in the parent attribute.
      源代码 (XML)
      <property version="2.13.0.1" name="my_node_base2" guid="cccd50e4431ddaeaf01dcb394fc988def578b380" parent="d99ebc8ef5769d70b1e46992309cc3e7d1aa2faa"/>
    If the inherited property is also manual, the corresponding *.prop file stores the name of the property, and the name of its parent in the parent_name attribute.
    注意
    Only manual properties can refer to their parent manual property by name.Only manual properties can refer to their parent manual property by name.
    源代码 (XML)
    <property version="2.13.0.1" name="my_node_base1" parent_name="node_base" manual="1"/>
    Only manual properties can refer to their parent manual property by name.If the inherited property is not manual (i.e it is a user property), the corresponding *.prop file stores a GUID of the user property, and the GUID of its parent (generated at run time from the parent's name) in the parent attribute.
    源代码 (XML)
    <property version="2.13.0.1" name="my_node_base2" guid="cccd50e4431ddaeaf01dcb394fc988def578b380" parent="d99ebc8ef5769d70b1e46992309cc3e7d1aa2faa"/>
    父级: 手动属性(包括基本属性)
    • If the inherited property is also manual, the corresponding *.prop file stores the name of the property, and the name of its parent in the parent_name attribute.
      注意
      Only manual properties can refer to their parent manual property by name.Only manual properties can refer to their parent manual property by name.
      源代码 (XML)
      <property version="2.13.0.1" name="my_node_base1" parent_name="node_base" manual="1"/>
      Only manual properties can refer to their parent manual property by name.
      如果继承的属性也是手动属性,则相应的*.prop文件将属性的名称及其父项的名称存储在parent_name属性中。
      注意
      Only manual properties can refer to their parent manual property by name.只有手册属性可以按名称引用其父级手册属性。
      源代码 (XML)
      <property version="2.13.0.1" name="my_node_base1" parent_name="node_base" manual="1"/>
    • If the inherited property is not manual (i.e it is a user property), the corresponding *.prop file stores a GUID of the user property, and the GUID of its parent (generated at run time from the parent's name) in the parent attribute.
      源代码 (XML)
      <property version="2.13.0.1" name="my_node_base2" guid="cccd50e4431ddaeaf01dcb394fc988def578b380" parent="d99ebc8ef5769d70b1e46992309cc3e7d1aa2faa"/>
      如果继承的属性不是手动属性(即它是用户属性),则对应的*.prop文件将用户属性的GUID和其父项的GUID(在运行时根据父项的名称生成)存储在parent属性中。
      源代码 (XML)
      <property version="2.13.0.1" name="my_node_base2" guid="cccd50e4431ddaeaf01dcb394fc988def578b380" parent="d99ebc8ef5769d70b1e46992309cc3e7d1aa2faa"/>
  • Parent: user property. The *.prop file of the inherited user property stores a GUID of the user property, and the GUID of its parent in the parent attribute.
    源代码 (XML)
    <property version="2.13.0.1" name="my_node_base3" guid="cd3ebc8ef5769d70b1e46452309cc3e7d1aa2ccd" parent="cccd50e4431ddaeaf01dcb394fc988def578b380"/>
    父级:用户属性。继承的用户属性的*.prop文件在parent属性中存储用户属性的GUID及其父项的GUID。
    源代码 (XML)
    <property version="2.13.0.1" name="my_node_base3" guid="cd3ebc8ef5769d70b1e46452309cc3e7d1aa2ccd" parent="cccd50e4431ddaeaf01dcb394fc988def578b380"/>
最新更新: 2024-08-16
Build: ()