Suppose I have some UObject subclass called UMyObject and I have a TSubclassOf<UMyObject>MyClass that is a blueprint class derived from UMyObject, how do I create a new instance of MyClass and get a UMyObject* pointer to it?
UCLASS()
class UMyObject : public UObject { /*...*/ }
doesn’t work properly for me …
it has very weird behavior, like the object is only half valid … it looks fine until i use a function from it, and then it acts like a nullptr obj …
the object works fine when i build it with ConstructObjectFromClass with blueprint.
A bit more advanced, but you can also use AddToRoot() if you don’t store it to a member, and that will make the object unaffected by garbage collection, but then you need to keep track of it, and remove it from root respectively when not needed anymore