// MyObject.h
UCLASS(DefaultToInstanced, EditInlineNew, Blueprintable) // Add DefaultToInstanced & EditInlineNew
class TESTING_API UMyObject : public UObject {
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere)
int MyValue = 10;
};
// MyPawn.h
UCLASS()
class TESTING_API AMyPawn : public APawn {
GENERATED_BODY()
public:
AMyPawn();
UPROPERTY(Instanced, EditAnywhere)
UMyObject* MyObject;
};
// MyPawn.cpp
AMyPawn::AMyPawn(){
MyObject = CreateDefaultSubobject<UMyObject>(TEXT("MyObject"));
}
This is how it looks in the editor: