Why can't we use TArray of TWeakObjectPtr from C++ to blueprint ?
Consider this kind of code :
I get a compilation error like this :
My goal is to create a blueprint from that Cpp Class, to add meshes and basic logic more easely than writting every thing, and I keep Cpp for more advanced/algorythmic stuff.
Obviously I don't want to deal with dangling pointer in my arrays, as I allow those arrays to be filled by in blueprint or in the editor. TWeakObjectPtr seamed to be the perfect wrapping class, I could use IsValid() to be sure of the state of my Actors etc.
I guess from the very few other threads talking about that, if I use a TArray< Actor *> it will work, but isn't it a nightmare to manipulate an array of raw object my class don't have ownership of and that can be destroyed anywhere else in the engine ?
What would be a better, or at least more common approach in unreal guide lines here ? Thanks
TWeakObjectPtr type is not supported by reflection system or blueprint itself, this type was made for use outside of it (for example Slate which powers UMG as it complitly outside reflection system). All variables visible to engine with UPROPERTY() are already managed, they will automatically null pointers to all properly deleted UObjects, so no need to use those special pointer types on UPROPERTY() variables (or else some specific container type don't cooperate with garbage collection, but all blueprint supported type should)
Follow this question
Once you sign in you will be able to subscribe for any updates here