编程语言
首页 > 编程语言> > 【UE4 C++】动态修改材质参数

【UE4 C++】动态修改材质参数

作者:互联网

普通使用

//头文件
UMaterialInstanceDynamic* PointerMaterial;
UMaterialInstanceDynamic* MiniMapmatInstDynamic;

//构造函数调用
static ConstructorHelpers::FObjectFinder<UMaterialInstance> StaticPointMaterialIns(TEXT("MaterialInstanceConstant'/Game/Material/M_PointInst.M_PointInst'"));
PointerMaterial = (UMaterialInstanceDynamic*)StaticPointMaterialIns.Object;

// 普通函数调用
static UMaterialInterface* MiniMapmatInst = LoadObject<UMaterialInterface>(NULL, TEXT("MaterialInstanceConstant'/Game/Material/M_MiniMapInst.M_MiniMapInst'"));
UMaterialInstanceDynamic MiniMapmatInstDynamic = UMaterialInstanceDynamic::Create(MiniMapmatInst, nullptr);

// 设置参数
PointerMaterial->SetScalarParameterValue(FName("Range"), Range);

MiniMapmatInstDynamic->SetTextureParameterValue(FName("MiniMapTex"), MiniMapRender);

为UStaticMeshComponent 创建


附录

标签:Category,Material,const,material,C++,Rendering,value,UE4,材质
来源: https://www.cnblogs.com/shiroe/p/15632289.html