查看: 429|回复: 8

[可视化蓝图脚本] 【Using Macro Libraries | Unreal Engine】

[复制链接]

1

主题

342

帖子

7万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
75866
发表于 2016-6-27 15:58:32 | 显示全部楼层 |阅读模式



A Macro Library is a container that holds a collection of Macros or self-contained graphs that can be placed as nodes in other Blueprints. These can be time-savers as they can store commonly used sequences of nodes complete with inputs and outputs for both execution and data transfer.
Creating a Macro Library
In this example we create a Macro Library consisting of two macros, one of which is used to add to a "Health" variable and the other is used to adjust the size of an Actor that is specified.

For this example, we are using the Blueprint Third Person Project with Starter Content enabled.

Right-click in an empty space in the Content Browser then in the context menu under Blueprints, select Blueprint Macro Library.

【虚幻4翻译文档-Using Macro Libraries | Unreal Engine】[虚幻4中文文档]



In the Pick Parent Class window that appears, select your Parent Class (for this example, select Actor).

【虚幻4翻译文档-Using Macro Libraries | Unreal Engine】[虚幻4中文文档]



Enter a name for your Macro Library, then Double-click on it to open it up.

【虚幻4翻译文档-Using Macro Libraries | Unreal Engine】[虚幻4中文文档]



This will display the Blueprint Macro interface.

【虚幻4翻译文档-Using Macro Libraries | Unreal Engine】[虚幻4中文文档]



In the MyBluprint window in the upper-right, rename the default macro to ScaleUp by pressing F2 on it.

In the Details panel for the ScaleUp macro, add the Inputs and Outputs shown below.

【虚幻4翻译文档-Using Macro Libraries | Unreal Engine】[虚幻4中文文档]



Above we have created two inputs, one called In set to the Exec type and the other called InActor set to the Actor type. The output added is called Out and is set to the Exec type. We will use these to determine the Actor that we want to affect through this macro.

In the graph for the ScaleUp macro, recreate the node network indicated below.

【虚幻4翻译文档-Using Macro Libraries | Unreal Engine】[虚幻4中文文档]



Above, when this macro is called it will get whatever Actor is provided as the InActor and get its current scale to which it will multiply it by 1.25 before setting it as the new scale 3D for the Target (which is the Actor specified as the InActor.) We can now use this macro with any Actor and affect their scale through the use of this macro.

Add another macro from the MyBlueprint window called AddHealth.

In the Details panel for AddHealth, add the Inputs and Outputs shown below.

【虚幻4翻译文档-Using Macro Libraries | Unreal Engine】[虚幻4中文文档]



Above we are taking in a float value called GetHealth which we will add to before we pass it through to the SetHealth output node.

In the graph for the AddHealth macro, recreate the node network indicated below.

【虚幻4翻译文档-Using Macro Libraries | Unreal Engine】[虚幻4中文文档]



Above we are adding 50 to whatever float value is provided as the GetHealth value before outputting the resulting value to SetHealth.

Save and close the Blueprint Macro Library.

Inside the Content/ThirdPersonBP/Blueprints folder, open the ThirdPersonCharacter Blueprint.

In the MyBlueprint window, add a Float variable to represent Health (we left the default value to 0).

【虚幻4翻译文档-Using Macro Libraries | Unreal Engine】[虚幻4中文文档]



In the Event Graph, recreate the node network indicated below.

【虚幻4翻译文档-Using Macro Libraries | Unreal Engine】[虚幻4中文文档]



Above we are calling the AddHealth macro whenever Q is pressed which takes in the Health variable (performs the macro script of increasing it) and updates it with the out pin SetHealth before printing it to the screen. We then use E and check if Health is greater than 100 before we allow the ScaleUp macro to be called on the Actor Self which is the ThirdPersonCharacter.

Compile and Play in the editor.

To better see the text printed to the screen, watch the video above in fullscreen.

In the video above, we included the Blueprint Script from step 13 so that we can see when the script is being fired. When we press E to attempt to call the ScaleUp macro, we first check the Health value which by default we set to 0. We then press Q to call the AddHealth macro to increase the Health variable each time it is pressed by 50. After a few presses, we then try the ScaleUp macro again and now we can see that it gets the call because our Health has been increased and is greater than 100.

These macros can be called from any other Blueprints provided the inputs for Health and the Target Actor are supplied.



   



   
【虚幻4翻译文档-Using Macro Libraries | Unreal Engine】[虚幻4中文文档]



      




   


      相关页面

  




       宏








      蓝图宏库








      蓝图可视化脚本




回复

使用道具 举报

0

主题

833

帖子

2770

积分

vip会员

Rank: 1

积分
2770
发表于 2016-7-2 19:57:11 | 显示全部楼层
回复看看!!!!!!!!!楼主辛苦
回复 支持 反对

使用道具 举报

0

主题

872

帖子

2903

积分

vip会员

Rank: 1

积分
2903
发表于 2016-7-4 02:37:06 来自手机 | 显示全部楼层
楼主好人!
回复 支持 反对

使用道具 举报

0

主题

810

帖子

2664

积分

vip会员

Rank: 1

积分
2664
发表于 2016-7-4 12:08:36 | 显示全部楼层
感谢分享,学习一下!
回复 支持 反对

使用道具 举报

0

主题

845

帖子

2850

积分

vip会员

Rank: 1

积分
2850
发表于 2016-7-4 23:49:03 | 显示全部楼层
谢谢支持。
回复 支持 反对

使用道具 举报

0

主题

863

帖子

2886

积分

vip会员

Rank: 1

积分
2886
发表于 2016-7-13 07:21:44 来自手机 | 显示全部楼层
我来看看 这个怎么样
回复 支持 反对

使用道具 举报

0

主题

1222

帖子

3875

积分

vip会员

Rank: 1

积分
3875
发表于 2016-7-19 02:52:57 来自手机 | 显示全部楼层
看看!便宜就好了
回复 支持 反对

使用道具 举报

0

主题

856

帖子

2859

积分

vip会员

Rank: 1

积分
2859
发表于 2016-7-22 08:23:30 来自手机 | 显示全部楼层
谢谢版主分享,现在又看到它了,我就不能放弃,
回复 支持 反对

使用道具 举报

0

主题

818

帖子

2700

积分

vip会员

Rank: 1

积分
2700
发表于 2016-7-24 22:46:32 来自手机 | 显示全部楼层
这个支持了呀,不错,顶顶帖拿拿钱
回复 支持 反对

使用道具 举报

*滑块验证:
您需要登录后才可以回帖 登录 | enginedx注册

本版积分规则

 
 



邮件留言:


 
返回顶部