Hi. I’m trying to pass MaterialsToSet
by reference to a FStreamableDelegate
and I get a compile error. I’m not sure if MaterialsToSet
is the only problem, but if anyone could tell me what I’m missing, or has general tips for improvement - that would be greatly appreciated. Oh, and please don’t mind my undescriptive variable names… Will be updated.
Cheers!
void AMCharacter::SetArmorMesh(
USkeletalMesh* ArmorMesh,
FMCharacterBodyMeshMaterial BodyMeshMaterial,
FName BodyMaterialSlot,
uint8 LoadCounter,
TArray<FSkeletalMaterial>& MaterialsToSet)
{
CurrentAssetsLoading++;
LoadCounter = 0;
TObjectPtr<UAssetManager> Manager = UAssetManager::GetIfInitialized();
if (!BodyMaterialSlot.IsNone())
{
LoadCounter++;
if (Manager)
{
FPrimaryAssetId Id_BodyMaterial = FPrimaryAssetId("CharacterBodyMaterial", CharacterInfo.SkinColor);
FStreamableDelegate Delegate_BodyMaterial = FStreamableDelegate::CreateUObject(
this,
&AMCharacter::OnBodyMaterialLoaded,
ArmorMesh,
Id_BodyMaterial,
BodyMaterialSlot,
LoadCounter,
MaterialsToSet);
Manager->LoadPrimaryAsset(Id_BodyMaterial, NoBundle, Delegate_BodyMaterial);
}
}
if (BodyMeshMaterial.BodyTextureSlot.IsNone())
{
FSkeletalMaterial ArmorMaterial = FSkeletalMaterial(BodyMeshMaterial.Material.Get(), false, false, BodyMeshMaterial.MaterialSlot);
MaterialsToSet.Add(ArmorMaterial);
FinalizeArmorMesh(ArmorMesh, MaterialsToSet, LoadCounter);
}
else
{
LoadCounter++;
if (Manager)
{
FPrimaryAssetId Id_BodyTexture = FPrimaryAssetId("CharacterBodyTexture", CharacterInfo.SkinColor);
FStreamableDelegate Delegate_BodyTexture = FStreamableDelegate::CreateUObject(
this,
&AMCharacter::OnBodyTextureLoaded,
ArmorMesh,
BodyMeshMaterial,
Id_BodyTexture,
LoadCounter,
MaterialsToSet
);
Manager->LoadPrimaryAsset(Id_BodyTexture, NoBundle, Delegate_BodyTexture);
}
}
}
Here’s the definition of FMCharacterBodyMeshMaterial
:
USTRUCT(BlueprintType)
struct FMCharacterBodyMeshMaterial
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TSoftObjectPtr<UMaterialInstance> Material;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FName MaterialSlot;
/** If the material uses a Body Texture, put the Slot Name here */
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FName BodyTextureSlot;
};
Compiler Error log:
MCharacter.cpp(455): error C2665: 'TDelegate<void (void),FDefaultDelegateUserPolicy>::CreateUObject': no overloaded function could convert all the argument types
E:\Epic Games\UE_5.3\Engine\Source\Runtime\Core\Public\Delegates\DelegateSignatureImpl.inl(295): note: could be 'TDelegate<void (void),FDefaultDelegateUserPolicy> TDelegate<void (void),FDefaultDelegateUserPolicy>::CreateUObject<AMCharacter,USkeletalMesh*&,FPrimaryAssetId&,FName&,uint8&,TArray<FSkeletalMaterial,FDefaultAllocator>&>(const UserClass *,void (__cdecl AMCharacter::* )(USkeletalMesh *,FPrimaryAssetId,FName,unsigned char,TArray<FSkeletalMaterial,FDefaultAllocator>) const,USkeletalMesh *&,FPrimaryAssetId &,FName &,uint8 &,TArray<FSkeletalMaterial,FDefaultAllocator> &)'
with
[
UserClass=AMCharacter
]