This page has been translated automatically.
UNIGINE 基础课程
1. 简介
3. 3D模型准备
4. 材质
5. 摄像机和光照系统
6. 实现应用程序逻辑
7. 制作过场动画与动画序列
8. 准备发布项目
9. 物理系统
10. 优化基础
11. 项目2:第一人称射击游戏
12. PROJECT3: Third-Person Cross-Country Arcade Racing Game
13. PROJECT4: VR Application With Simple Interaction

对象实例化

The virtual world that you create may contain many identical objects, such as electrical supports, cars, wheels, etc. These objects should always look the same, and if you clone them, many separate copies are created. This means that if you decide to make any changes to one of the copies (for example, change geometry or some materials of an object), you will have to do it for each copy separately.你创建的虚拟世界可能包含许多相同的对象,例如电线杆、汽车、轮子等。这些对象应该始终保持相同的外观,如果你克隆它们,会创建许多单独的副本。这意味着如果你决定对其中一个副本进行任何更改(例如更改对象的几何形状或某些材质),你必须为每个副本单独进行更改。

To avoid this, it is convenient to use a template and replicate its instances of it in the scene. UNIGINE has Node Reference for this purpose.为了避免这种情况,使用模板并在场景中复制其实例会很方便。UNIGINE为此提供了节点引用(Node Reference)。

First you create and customize a hierarchy of objects with assigned materials, components, physical parameters, and so on (for example, a helicopter with numerous nodes and parts). You save this finished template to a separate file (with the *.node extension), and then add instances of this template to the scene. Each of the added instances references the template.首先,你创建并自定义一个具有指定材质、组件、物理参数等的对象层次结构(例如带有许多节点和部件的直升机)。你将这个完成的模板保存到一个单独的文件(扩展名为*.node),然后将此模板的实例添加到场景中。每个添加的实例都引用该模板。

Creating and Exporting the Template Node
创建和导出模板节点#

To create a template of a complex object, you need to follow these steps:要创建复杂对象的模板,你需要按照以下步骤操作:

  1. Create the base hierarchy. Prepare the base hierarchy that will represent your object. For example, if you want to use a helicopter repeatedly in your world, assemble a hierarchy of nodes with materials, animations, logic components, and everything else that you need. 创建基础层次结构。准备将代表你对象的基础层次结构。例如,如果你想在你的世界中重复使用直升机,请组装一个包含材质、动画、逻辑组件和你需要的所有其他内容的节点层次结构。

  2. Convert the node hierarchy into a Node Reference. Simply drag and drop the root node of the hierarchy to the desired folder in Asset Browser. A corresponding *.node (template) asset containing the hierarchy will be created in the folder. The node hierarchy in the world will be replaced by a reference to this asset.将节点层次结构转换为节点引用。只需将层次结构的根节点拖放到资源浏览器中的目标文件夹即可。将在该文件夹中创建一个包含层次结构的相应*.node(模板)资源。世界中的节点层次结构将被替换为此资源的引用。

  3. Place instances. The first instance in the world is the one that replaced the hierarchy when you dragged it into Asset Browser. You can add other instances by dragging the desired *.node template from Asset Browser directly to the scene or by cloning the Node Reference like any other node (Shift+Drag).放置实例。世界中的第一个实例是当你将层次结构拖到资源浏览器时替换层次结构的实例。你可以通过从资源浏览器直接将所需的*.node模板拖到场景中,或像任何其他节点一样克隆节点引用(Shift+拖拽)来添加其他实例。

Benefits When Editing
编辑时的优势#

When you edit any instance and save the changes, the template and all other instances are automatically updated. This approach ensures integrity when changing the parameters of reusable objects, especially if they are complex. This process looks as follows:当你编辑任何实例并保存更改时,模板和所有其他实例都会自动更新。这种方法在更改可重用对象的参数时确保了完整性,特别是当它们很复杂时。这个过程如下所示:

  1. Select any instance in the world through the Editor Viewport or World Nodes Hierarchy window. The Node Reference parameters will be displayed in the Parameters window.通过 Editor Viewport 或世界节点层次结构窗口选择世界中的任何实例。节点引用参数将显示在参数窗口中。

  2. Click Edit. The hierarchy of the original Node Reference will be displayed in the World Nodes Hierarchy window.点击 Edit。原始节点引用的层次结构将显示在世界节点层次结构窗口中。

  3. Edit the source Node Reference. You can make any changes: change materials, add new nodes, delete existing nodes, etc.编辑源节点引用。你可以进行任何更改:更改材质、添加新节点、删除现有节点等。
  4. Click Apply to save your changes or Cancel to discard them. The changes will be applied to all instances at once.点击 Apply 保存你的更改或点击 Cancel 放弃它们。更改将立即应用于所有实例。

Important Notes
重要注意事项#

A Node Reference can contain only one root node.一个节点引用只能包含一个根节点。

Referencing the Node Reference Content from Outside
从外部引用节点引用内容#

Node Reference should be thought of as a container for a self-sufficient hierarchy of nodes. When designing your world in UnigineEditor, avoid referencing nodes that are stored in a Node Reference directly from the outside (e.g. when creating physical joints, specifying nodes in component parameters or the target node of Player Persecutor, or when controlling nodes animation via the Tracker tool that we'll review a bit later) as such references will be lost as soon as the world is reloaded.节点引用应被视为自给自足的节点层次结构的容器。在UnigineEditor中设计你的世界时,避免直接从外部引用存储在节点引用中的节点(例如在创建物理关节、在组件参数中指定节点或 Player Persecutor 的目标节点时,或通过我们稍后将介绍的 Tracker 工具控制节点动画时),因为当世界重新加载时,这些引用将丢失。

Transformations
变换#

The transformation of Node Reference is not affected by the transformation of the nodes stored in it. Thus, logic-driven and physics-driven nodes inside Node Reference will make no influence on its direct children.节点引用的变换不受其中存储的节点变换的影响。因此,节点引用内部的逻辑驱动和物理驱动节点不会对其直接子节点产生影响。

In the following example, the moving grouped Node_1 and Node_2 nodes (e.g. driven by physics) contained by a Node Reference will not change the transformation of the Node Reference and, therefore, the DirectChild node will not be affected as well.在以下示例中,由节点引用包含的移动分组 Node_1Node_2 节点(例如由物理驱动)不会改变节点引用的变换,因此 DirectChild 节点也不会受到影响。

节点引用内容的示意图

Schematic representation of Node Reference content节点引用内容的示意图

So, it is recommended to enclose all interconnected nodes in a single Node Reference to ensure logical and hierarchical integrity.因此,建议将所有互连节点封装在单个节点引用中,以确保逻辑和层次结构的完整性。

本页面上的信息适用于 UNIGINE 2.20 SDK.

最新更新: 2025-06-09
Build: ()