Suppose I have a USTRUCT that looks like this
USTRUCT() struct MyStruct { GENERATE_BODY() UPROPERTY() AActor* ActorRef; };
If the actor referenced by ActorRef is detroyed somewhere else, would ActorRef eventually be set to nullptr by GC? Is there any requirement on how I create this USTRUCT? Can I use a C++ new?
ActorRef
new
The UE Reflection system will help you null pointers if it is visible to the reflection system.
The pointer needs to be a UPROPERTY but a USTRUCT should also be saved as a UPROPERTY otherwise it will hide its members.
Never use new together with the UE Reflection system.
In general you should never use new but rather smart pointers.