My Data Asset:
.h file
#pragma once
#include "CoreMinimal.h"
#include "Core/GameAssetManager.h"
#include "Engine/DataAsset.h"
#include "PlayerCharacter.generated.h"
/** Base class for all playable characters and mods */
UCLASS()
class DMTest_API UPlayerCharacter : public UPrimaryDataAsset
{
GENERATED_BODY()
public:
UPlayerCharacter(): WalkSpeed(0), RunSpeed(0)
{
ItemType = UGameAssetManager::PlayerCharacter;
}
// Type of this asset, set in native parent class
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Character)
FPrimaryAssetType ItemType;
// User-visible short name
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Character)
FText Name;
// User-visible long description
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Character)
FText Description;
// Icon to display
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Character)
TSoftObjectPtr<UTexture2D> Icon;
//Skeletal mesh of this character
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Character)
TSoftObjectPtr<USkeletalMesh> CharacterMesh;
// Walk speed
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Movement)
int32 WalkSpeed;
// Walk speed
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Movement)
int32 RunSpeed;
/**
* @return Returns the logical name, equivalent to the primary asset id
*/
UFUNCTION(BlueprintCallable, Category = Item)
FString GetIdentifierString() const;
/** Overridden to use saved type */
virtual FPrimaryAssetId GetPrimaryAssetId() const override;
};
.cpp file
#include "Characters/PlayerCharacter.h"
FString UPlayerCharacter::GetIdentifierString() const
{
return GetPrimaryAssetId().ToString();
}
FPrimaryAssetId UPlayerCharacter::GetPrimaryAssetId() const
{
return FPrimaryAssetId(ItemType, GetFName());
}
I have 2 properties for the data in my character class
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Character Data", meta=(AllowPrivateAccess="true"))
TSoftObjectPtr<UPlayerCharacter> CharacterDataAsset;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Character Data", meta=(AllowPrivateAccess="true"))
TObjectPtr<USkeletalMesh> SkeletalMesh;
I can load everything from CharacterDataAsset but CharacterMesh, if I change TSoftObjectPtr to TObjectPtr, then I can load CharacterMesh. So, what did I do wrong?