|
怎么在编辑时通过代码修改场景中蓝图里的材质或者声音!
纹理变量的修改方法,思路如上次写的思路
for (int32 ActorIdx = 0; ActorIdx GWorld- GetCurrentLevel()- Actors.Num(); ++ActorIdx)
{
//获取到关卡蓝图
AActor* pActor = GWorld- GetCurrentLevel()- Actors[ActorIdx];
bool find = false;
if (pActor == NULL) continue;
FString ActorName = pActor- GetName();
//此处获取第一级组件名称
if (ActorName == OutResults[0])
{
UClass*objclass = pActor- GetClass();
UProperty* property;
property = objclass- PropertyLink;
while (property != NULL)
{
UProperty*property1 = property- PropertyLinkNext;
if (property1- GetName() == OutResults[1])
{
property = property1;
find = true;
break;
}
property = property1;
}
if (find)
{
//获取地址
USoundBase** DestAddress = (property- ContainerPtrToValuePtr USoundBase* (pActor));
USoundBase* StaticActor = (*DestAddress);
TCHAR *pAssetPath = name[0];
//加载新图片
USoundBase* newTexture = LoadObject USoundBase (nullptr, pAssetPath, nullptr, LOAD_None, nullptr);
//替换资源
*DestAddress = newTexture;
}
}
} |
|