使用蓝图和C++动态创建材质(Material)并设置材质参数属性(Parameter)【UE4】【C++】【Blueprint】

蓝图方式

1、创建一个继承自Actor名为RandomChair的蓝图。

使用蓝图和C++动态创建材质(Material)并设置材质参数属性(Parameter)【UE4】【C++】【Blueprint】

2、打开蓝图,将椅子的StaticMesh拖放到根节点内。

使用蓝图和C++动态创建材质(Material)并设置材质参数属性(Parameter)【UE4】【C++】【Blueprint】

3、在该蓝图中创建一个Box,用于碰撞检测。

使用蓝图和C++动态创建材质(Material)并设置材质参数属性(Parameter)【UE4】【C++】【Blueprint】

使用蓝图和C++动态创建材质(Material)并设置材质参数属性(Parameter)【UE4】【C++】【Blueprint】

4、将蓝图拖到场景中。

使用蓝图和C++动态创建材质(Material)并设置材质参数属性(Parameter)【UE4】【C++】【Blueprint】

5、添加蓝图脚本

在构造函数中创建一个材质实例,命名为DynamicMetarial。

使用蓝图和C++动态创建材质(Material)并设置材质参数属性(Parameter)【UE4】【C++】【Blueprint】

使用蓝图和C++动态创建材质(Material)并设置材质参数属性(Parameter)【UE4】【C++】【Blueprint】

使用蓝图和C++动态创建材质(Material)并设置材质参数属性(Parameter)【UE4】【C++】【Blueprint】

使用蓝图和C++动态创建材质(Material)并设置材质参数属性(Parameter)【UE4】【C++】【Blueprint】

添加Box的碰撞事件函数。

使用蓝图和C++动态创建材质(Material)并设置材质参数属性(Parameter)【UE4】【C++】【Blueprint】

使用蓝图和C++动态创建材质(Material)并设置材质参数属性(Parameter)【UE4】【C++】【Blueprint】

ColorSeats是Chair材质中定义可编辑的参数。

使用蓝图和C++动态创建材质(Material)并设置材质参数属性(Parameter)【UE4】【C++】【Blueprint】