Hi, I’m working on a subsystem for SaveGame data.
And I want to be able to handle any data with the same process.
Thus I thought it would be handy to get the return value in the same class type that I specify as input.
Sadly, I can’t seem to make it work.
This is the code I have:
UFUNCTION(BlueprintCallable, Category = SaveDataSubsystem, meta = (DeterminesOutputType = "dataClass"))
USaveGameGlobalBase* LoadGlobalData(TSubclassOf<USaveGameGlobalBase> dataClass) {
//return NewObject<USaveGameGlobalBase>(this, NAME_None, RF_NoFlags, dataClass->GetDefaultObject());
return NewObject<USaveGameGlobalBase>(dataClass->GetClass());
}
In my level blueprint, I have created a reference to the SaveDataSubsystem.
Then when I set the LoadGlobalData’s DataClass value to SG_Global_Test which contains AudioVolumeChannel floats.
It says the return type is SG_Global_Test. How ever the cast fails, so it must actually be of the parent type.
What am I doing wrong here?
EDIT: Not sure if it matters. But the class SG_Global_Test is created as a blueprint type and not in c++.