Unreal4折叠图表0028bate1
折叠图表
将节点折叠为新图表、函数或宏。
本页讲述将 Blueprint 图表折叠为一个单独节点、一个 函数 或一个 宏 的多种方法。将大型图表折叠为一个连接图表,便于清理。
折叠节点
下图表现的是最简单的折叠方法,将 折叠节点 转变为连接图表。它主要用于组织,使事件图表中的内容整齐清楚。
1.在 蓝图 的 图表 上找到需要折叠的节点。

此处有一些在玩家跳跃后减少其能量的节点。
2.在节点上 单击左键 并拖动,选择需要折叠的所有节点。

可通过 Control + 左键单击 组合键从选择中添加/减去节点。
3.选定需要折叠的节点后,在选中的任意节点上 单击右键 并选择 Collapse Nodes。

4.所有节点将折叠为一个单独的 Collapsed Graph 节点,然后可为该节点命名。

5.鼠标悬停在 Collapsed Graph 节点上,可以看到节点网络的预览窗口。

6.双击 Collapsed Graph 节点将打开含所选节点的新图表。

7.在 Collapsed Graph 中,可从 Details 面板添加引脚至 Inputs 或 Outputs 节点。

折叠时将默认添加 Execute,在此添加两个 Execute 输出引脚:OutOfEnergy 和 CanJump。
我们也对图表进行了修改,在扣除玩家拥有的能量之前确定能量是否已经耗尽。

带折叠节点的 事件图表 外观如下图所示。

8.在折叠节点上 单击右键,可选择 Expand Node 将节点转换为其原始状态。

折叠为函数
折叠节点的另一种方式是将它们折叠为一个 函数。较之于折叠图表,将节点折叠为函数有下列优点:基于任意指定参数在脚本的另一区域调用函数、在另一蓝图中调用函数(需为包含要调用函数的蓝图添加引用)。
下列步骤说明如何将节点折叠为函数。
1.选中需要折叠的节点,在其中一个节点上 单击右键 并选择 Collapse to Function。

2.一个新 Function 将被创建,可在 MyBlueprint 窗口按 F2 键对其进行重命名。

编译蓝图后,"WARNING!"报错信息将自动消失。

3.双击 函数在一个新图表窗口中将其打开。

和折叠图表相似,可点击 Inputs 或 Outputs 节点,通过 Details 面板为其添加引脚。
4.可通过函数名指定其在何时被调用。

5.在函数上 单击右键 并选择 Expand Node 可恢复折叠前的原始状态。
折叠为宏
除折叠为折叠图表和函数外,还可将节点折叠为 宏。如此理解宏方为最佳:选取相连的数个节点,将它们合并为单个节点,便于执行整体操作。利用其执行高频率操作(如复杂数学方程式)十分实用。
下列步骤讲述如何将节点折叠为宏。
1.选中需要折叠的节点,在其中一个节点上 单击右键 并选择 Collapse to Macro。

2.一个新宏节点创建成功,可在 MyBlueprint 窗口按 F2 键对其进行重命名。

3.双击 可将宏打开。

利用此方法可随意添加 输入 或 输出 引脚。
下图事件图表应用了带额外引脚的宏。

4.在宏上 单击右键,可选择 Expand Node 将节点转换为其原始状态。