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
材质和着色器
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

状态

State allows you to set a mode for rendering passes and a value for rendering options. States change a set of generated definitions passed to shaders, so any changes made to a state cause shaders recompilation. A material state generates defines for shaders only if the state meets the conditions. You can specify your own states or use and specify values for UNIGINE's internal states.状态允许您设置渲染通道的模式和渲染选项的值。状态会更改一组传递给着色器的生成定义,因此对状态所做的任何更改都会导致着色器重新编译。仅当状态满足条件时,材质状态才会为着色器生成定义。您可以指定自己的状态或使用并指定 UNIGINE 内部状态的值。

The syntax is the following:语法如下:

ULON
StateType state_name = value(s)

You can acces states in the shader using the following defines:您可以使用以下定义访问着色器中的状态:

UUSL
GET_STATE_<state name in uppercase> = value // for all states

STATE_<state name> // if the state value is bigger than 0 (for example, StateToogle)

STATE_<state name>_<name of an element from the items array> // for State and StateSwitch

To change the state's values use the corresponding API methods.要更改状态的值,请使用相应的API 方法.

Types of States
国家类型#

  • StateToggle (bool) — a switch that enables/disables the stateStateToggle (bool) — 启用/禁用状态的开关
  • StateSwitch (integer) — a multiple-value switch based on array of items (mandatory argument)StateSwitch (integer) — 基于项目数组的多值开关(强制参数)
  • StateInt (integer) — a state with an integer number (used to pass the state value via the API to the shader)StateInt (integer) — 具有整数的状态(用于通过 API 将状态值传递给着色器)
  • State — auto detection of the state type (if the items argument is present, then StateSwitch; otherwise StateToggle)State — 自动检测状态类型(如果存在 items 参数,则为 StateSwitch;否则为 StateToggle

Usage Examples
使用示例#

Suppose we got the base material with these states defined:假设我们得到了定义了这些状态的基础材质:

ULON
BaseMaterial 
{
	State my_state_switch = 4 <items = [a b c d e]> // or StateSwitch my_state_switch = 4 <items = [a b c d e]>
	State my_state_toggle = 1
	StateInt my_state_int = 256 <internal = true>
}

Then the following defines are available in the shaders:然后在着色器中可以使用以下定义

UUSL
#define GET_STATE_MY_STATE_SWITCH 4
#define GET_STATE_MY_STATE_TOGGLE 1
#define GET_STATE_MY_STATE_INT 256

#ifdef STATE_MY_STATE_SWITCH_A
    /* some UUSL code */
#elif  STATE_MY_STATE_SWITCH_B
    /* some UUSL code */
#elif  STATE_MY_STATE_SWITCH_E
    /* some UUSL code */
#endif

#ifdef STATE_MY_STATE_TOGGLE
    /*some UUSL code*/
#endif

int my_state_int = GET_STATE_MY_STATE_INT;

Arguments
论据#

editable
editable#

Boolean

A flag indicating if state can be changed in the Parameters window or via API.指示状态是否可以在 Parameters 窗口或通过API .

Available values:可用值:

  • false — unchangeablefalse — 不可更改
  • true — changeable (by default)true — 可更改(默认)

title
title#

String

Title for the Editor.编辑的标题。

tooltip
tooltip#

String

Tooltip for the Editor.编辑器的工具提示。

switch_group
switch_group#

String

Sets this state to be responsible for the toggle of the specified group.将此状态设置为负责指定组的切换。

hidden
hidden#

Boolean

A flag indicating if the state is hidden in the Editor.指示状态是否在编辑器中隐藏的标志。

Available values:可用值:

  • false — shows the state in the Editorfalse — 显示编辑器中的状态
  • true — hides the state in the Editortrue — 在编辑器中隐藏状态

internal
internal#

Boolean

A flag indicating if the state is hidden in the Editor and the state values are not saved for the inherited materials.一个标志,指示状态是否在编辑器中隐藏,并且不为继承的材质保存状态值。

Available values:可用值:

  • false — shows the state in the Editor and saves the state values for the inherited materialsfalse — 在编辑器中显示状态并保存继承材质的状态值
  • true — hides the state in the Editor and does not save the state values for the inherited materialstrue — 在编辑器中隐藏状态并且不保存继承材质的状态值

items
items#

Array of Strings字符串数组

Items used for the StateSwitch type.用于的项目状态开关类型。

pass
pass#

Array of Strings

Specifies what passes use this state.指定使用此状态的传递。

Available values:可用值:

注意

To make one or more passes use this state, write passes in square brackets and separate them with spaces. For example:要使一个或多个传递使用此状态,请将传递写在方括号中并用空格分隔它们。例如:

ULON
State wireframe_antialiasing <pass=[wireframe post custom_pass_name]>
最新更新: 2024-08-16
Build: ()