This page has been translated automatically.
视频教程
界面
要领
高级
实用建议
专业(SIM)
UnigineEditor
界面概述
资源工作流程
版本控制
设置和首选项
项目开发
调整节点参数
Setting Up Materials
设置属性
照明
Sandworm
使用编辑器工具执行特定任务
如何擴展編輯器功能
嵌入式节点类型
Nodes
Objects
Effects
Decals
光源
Geodetics
Sound Objects
Pathfinding Objects
Players
编程
基本原理
搭建开发环境
使用范例
C++
C#
UnigineScript
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

World Expression

World Expression is a point object, which executes arbitrary expressions (scripts) within the specified distance and at a set frame rate. By default, expressions are executed at the same frame rate as the main application.World Expression是一个点对象,它在指定范围内执行任意表达式(脚本)距离并在一组帧率。默认情况下,表达式以与主应用程序相同的帧速率执行。

注意
An expression is executed only if it's within the specified distance from the camera.仅当表达式在指定范围内时才执行距离从相机上。

By using World Expression, you can attach a script to an object in the scene. To do that, such object must be added as a child node to World Expression. Child nodes inherit transformations (if any) of the World Expression node.通过使用World Expression,可以将脚本附加到场景中的对象。为此,必须将此类对象作为子节点添加到World Expression。子节点继承World Expression节点的转换(如果有)。

注意
Child nodes are transformed relative to the pivot point of the World Expression node.相对于World Expression节点的枢轴点转换子节点。

If there are nested World Expression nodes, the child node of the last World Expression in the hierarchy inherits transformations of all parent World Expression nodes.如果存在嵌套的World Expression节点,则层次结构中最后一个World Expression的子节点将继承所有父World Expression节点的转换。

For example, by using World Expression, you can transform objects in the scene, turn on and off sounds with the distance, turn on and off NPC behavior, attach objects to the camera (e.g. drops of the rain on the camera), and so on.例如,通过使用World Expression,您可以变换场景中的对象,按一定距离打开和关闭声音,打开和关闭NPC行为,将对象附加到相机(例如,相机上的雨滴)等等。 。

Mesh Dynamic nodes added as children to the nested World Expression nodesMesh Dynamic节点作为子代添加到嵌套的World Expression节点

See also也可以看看#

Creating World Expression创造世界表达#

To create World Expression via UnigineEditor:要通过UnigineEditor创建World Expression,请执行以下操作:

  1. On the Menu bar, click Create -> Logic -> Expression.菜单栏,单击Create -> Logic -> Expression

  2. Place the World Expression somewhere in the world.World Expression放置在世界上的某个地方。

Attaching World Expression Script附加世界表达脚本#

There are two ways of attaching a World Expression script via UnigineEditor:有两种方法可以通过UnigineEditor附加World Expression脚本:

  • Directly in UnigineEditor in the Source field of the World Expression section in the Parameters window. Source code must be inside the curly braces {}, as they define the World Expression scope.直接在UnigineEditorParameters窗口中World Expression部分的Source字段中。源代码必须在花括号{}内,因为它们定义了World Expression范围。

  • Attached as a script file in the File field of the World Expression section. The script file should be included in the World Expression scope in the Source field using the curly braces {}:作为脚本文件附加World Expression部分的File字段中。脚本文件应使用花括号{}包含在Source字段的World Expression范围内:

    In this case, the my_expression.h file should contain the following code:在这种情况下,my_expression.h文件应包含以下代码:

    源代码 (UnigineScript)
    log.message("WorldExpression is updated\n");
    注意
    In the script file, the source code must not be wrapped in the curly braces {}.在脚本文件中,不得将源代码包装在花括号{}中。

Implementing Script实施脚本#

The script itself can be implemented as a simple sequence of functions' calls or as a set of functions and classes. See examples here.脚本本身可以实现为简单的函数调用序列,也可以实现为一组函数和类。查看范例这里

注意
It is recommended to implement simple scripts.建议实现简单的脚本。

Inter-Script Communication脚本间通信#

Such script can communicate with the world script via the corresponding engine.world class functions or with World Trigger via callbacks (see the samples listed above).这样的脚本可以与世界脚本交流通过相应的engine.world类函数或通过回调使用World Trigger(请参见列出的示例)以上)。

Script Functions脚本功能#

Besides functions of the UnigineScript library, there is also a set of internal functions that are available within the World Expression script. The list of such functions with descriptions and examples can be found here.除了UnigineScript库的函数外,在World Expression脚本中还提供了一组内部函数。可以找到带有说明和示例的此类功能的列表这里

Setting World Expression Parameters设置世界表情参数#

You can adjust the following parameters of World Expression in the Node tab: 您可以在Node选项卡中调整以下World Expression参数:

Update Distance Limit Distance from the camera, within which the expression is executed.距相机的距离,在该距离内执行表达式。
IFps A constant frame duration (inverse FPS, 1/FPS) used to execute the expression. If 0 is set, the expression is executed at the same frame rate as the main application.用于执行表达式的恒定帧持续时间(反向FPS,1 / FPS)。如果设置为0,则以与主应用程序相同的帧速率执行表达式。
File

A path to a file with a World Expression script to be executed. The path is relative to the data directory. This file should be included in the World Expression scope in the Source field. This field is optional as the World Expression script can be implemented directly via the UnigineEditor interface.要执行的带有World Expression脚本的文件的路径。该路径是相对于data目录的。该文件应包含在Source字段的World Expression范围内。该字段是可选的,因为可以通过UnigineEditor接口直接实现World Expression脚本。

注意
If the script file is changed, it should be refreshed via UnigineEditor: click to the right of the File field.如果脚本文件已更改,则应通过UnigineEditor对其进行刷新:单击File字段右侧的
Source

Source code of a World Expression script. This field can contain:World Expression脚本的源代码。该字段可以包含:

  • Direct implementation of the World Expression script直接执行World Expression脚本
  • The #include directive that loads the script file specified in the File field.#include指令加载脚本文件File字段中指定。
注意
In both cases, the curly braces {} must wrap the code in the field.在这两种情况下,花括号{}必须将代码包装在字段中。
最新更新: 2021-05-26
Build: ()