Hello,
I have a TArray of a UObject-derived class in an actor class I’ve written in code. The array is a UPROPERTY and the elements survive a restart of the editor. I create these objects and add them to the array in the editor by a Blutility method.
I’ve created a blueprint that derives from my actor to customize some of the default values. What happens is, if I have an instance of this blueprint in the level and populate the array, I can’t compile that blueprint anymore because those elements in the array all become null. I’ve checked and they are there until the compile.
So, why do they get garbage collected when I compile the blueprint?
Please note that you can use RF_RootSet flag as an argument in NewObject method during the initialization of your UObject-derived classes. This will prevent objects from being garbage collected even if they are not referenced.
Also, if you have Editable-type specifiers in the array declaration, please try changing them to Visible(VisibleAnywhere, VisibleInstanceOnly, VisibleDefaultsOnly).
Hey, thanks for the answer. I’ll put the flag but I’m worried that if the error is in my code, there may be objects floating around with this flag. Otherwise, it is a bug in the editor code.
Also, yeah I’ve learned that there are things like that that should not be editable after a blueprint corruption case I’ve had a month ago.
Edit: I’ve put the flag and it’s still happening. I get an Array of 72 NULLs :\