I create a new asset type which is json string, and add new type asset to project. I try to get the asset json string but failed. How to do it? The below is:
UCLASS()
class RICHTAPTOOLS_API URichtapClip : public UObject
{
GENERATED_BODY()
private:
/** clip data source, string info*/
/** clip duration, unit ms*/
int Duration;
UPROPERTY();
FString ClipData;
private:
URichtapClip();
~URichtapClip();
public:
FString FileName;
/** get richtap clip data duration*/
int GetDuration();
//void SetDuration(int Ms);
/** get richtap clip data*/
FString& GetData();
//void SetData(FString& Data);
/** load richtap clip data string*/
bool LoadData();
};
UCLASS()
class URichtapClipFactory : public UFactory
{
GENERATED_BODY()
public:
URichtapClipFactory();
virtual UObject* FactoryCreateFile(UClass* InClass, UObject* InParent, FName InName, EObjectFlags Flags, const FString& Filename, const TCHAR* Parms, FFeedbackContext* Warn, bool& bOutOperationCanceled);
//virtual UObject* FactoryCreateNew(UClass* InClass, UObject* InParent, FName InName, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn);
};
URichtapClip* Clip = LoadObject(nullptr, TEXT("/Game/haptic/me_1.me_1"));
The me_1.ue is my asset file of json string located in /content/haptic/me_1.ue. How can I read the json string data? If I use FFileHelper::LoadFileToString(ClipData, *FileName), it’s ok, but only for PIE. After packgae, it’s not work.
Thanks.