Hi, all! I would like to know about childldren of UObject instantiating.
For example I have following base class:
class UAbility : public UObject {
GENERATED_BODY()
public:
UAbility();
...
};
If I use it as Object reference in data table struct I can not set nor default value, nor value in specific row
Ok, it’s a not big deal I can use TSubclassOf< UAbility> and create object from class, but in general is it possible to have reference in data tables and other editor related views? Maybe I missed something, as I understand for any UCLASS and UObject children the default object is created, why can’t I use it?
So, next. I use TSubclassOf and create object :
auto ability = NewObject<UAbility>(this, Row->AbilityClass)// NAME_None, RF_NoFlags by default;
and store to component:
class UCharacterAttributesComponent : public UActorComponent
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, SaveGame)
TMap<FString, UAbility*> Abilities;
The issue is after save/load the map has correct amount of elements and keys of map, but all references to UAbility objects are empty.
And only if I use flag RF_Load on creation all works as expected.
auto ability = NewObject<UAbility>(this, Row->AbilityClass, NAME_None, RF_Load);
What is a magic here? RF_Load is combined flag, but idk which part of it does the save/load job. I doubt, it’s a good idea mark each created object as RF_ClassDefaultObject which is part of RF_Load. I could blindly check all of them, but I would like to understand what’s happening…
Thx for attention )