Commit d3d56775 authored by Kyrium's avatar Kyrium
Browse files

fix an error

parent 5199846e
......@@ -115,16 +115,22 @@ void UKBFLActorSpawnDescriptorBase::RemoveWrongActors(TArray<FTransform>& Transf
}
}
void UKBFLActorSpawnDescriptorBase::ApplyMaterialData(AActor* Actor, TMap<uint8, UMaterial*> MaterialInfo)
void UKBFLActorSpawnDescriptorBase::ApplyMaterialData(AActor* Actor, TMap<uint8, UMaterialInterface*> MaterialInfo)
{
UStaticMeshComponent* StaticMesh = Cast<UStaticMeshComponent>(Actor->GetComponentByClass(UStaticMeshComponent::StaticClass()));
if(StaticMesh && MaterialInfo.Num() > 0)
if(Actor && MaterialInfo.Num() > 0)
{
for (auto Info : MaterialInfo)
if(UActorComponent* PrimitiveComponent = Actor->GetComponentByClass(UStaticMeshComponent::StaticClass()))
{
if( StaticMesh->GetNumMaterials() > Info.Key && Info.Value )
UStaticMeshComponent* StaticMesh = Cast<UStaticMeshComponent>(PrimitiveComponent);
if(StaticMesh)
{
StaticMesh->SetMaterial(Info.Key, Info.Value);
for (auto Info : MaterialInfo)
{
if( StaticMesh->GetNumMaterials() > Info.Key && Info.Value )
{
StaticMesh->SetMaterial(Info.Key, Info.Value);
}
}
}
}
}
......
......@@ -13,7 +13,7 @@ void UKBFLResourceNodeDescriptor_ResourceNode::ForeachLocations(TArray<FTransfor
AActor* OutActor;
if(!CheckActorInRange(Location, OutActor) && IsRangeFree(Location))
{
SpawnActorAtLocation(Location, GetActorClass());
OutActor = SpawnActorAtLocation(Location, GetActorClass());
}
if(OutActor)
......
......@@ -32,7 +32,7 @@ class KBFL_API UKBFLActorSpawnDescriptorBase : public UObject
virtual void ModifySpawnedActorPostSpawn(AActor*& InActor);
virtual void AfterSpawning() {};
void ApplyMaterialData(AActor* Actor, TMap<uint8, UMaterial*> MaterialInfo);
void ApplyMaterialData(AActor* Actor, TMap<uint8, UMaterialInterface*> MaterialInfo);
virtual bool IsAllowedToRemoveActor(AActor* InActor);
bool CheckWorld() const;
......
......@@ -52,5 +52,5 @@ class KBFL_API UKBFLResourceNodeDescriptor_ResourceNode : public UKBFLResourceNo
TSubclassOf<AFGResourceNodeBase> mResourceNodeClass = nullptr;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category="Resource Node")
TMap<uint8, UMaterial*> mResourceNodeMaterialInfo;
TMap<uint8, UMaterialInterface*> mResourceNodeMaterialInfo;
};
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment