Hi, so I seem to be having an issue with setting UObjects as UPropertys, I listed two experiments here as they are related and I assume I am making the same mistake both times. The only part I have gotten to work properly is using TSubclass as a property, then creating the object from there. So I have listed below the experiments I did:
The variable is set up in the AGameMode subclass using the following code:
UPROPERTY(EditAnywhere)
class USquadHub* SquadHub;
The USquadHub clas is declared as:
UCLASS(Blueprintable, BlueprintType, DefaultToInstanced, EditInlineNew)
class TMO_API USquadHub : public UObject
From reading the class specifiers page, I thought DefaultToInstanced and EditInlineNew would create an instance of the object if I assigned the USquadHub class to the SquadHub variable. I can assign the variable:
![]()
However as soon as the blueprint compiles the value is lost and reverts back to this
![]()
The other thing is creating an instance of the squadhub in the constructor of the object which maintains the pointer to the squad hub object. I assumed this would set a default squadhub object. So in the constructor for the gamemode:
ATMOGameMode::ATMOGameMode()
{
SquadHub = NewObject<USquadHub>();
}
The DefaultToInstanced and EditInlineNew UClass modifiers were dropped:
UCLASS(Blueprintable, BlueprintType)
class TMO_API USquadHub : public UObject
So same issue again, straight after the compile of the C++ code

However again after the compile

So I am assuming the cause of this is the same issue, any help on this would be greatly appreciated.
Thanks so much for any help