If you have a property use TWeakObjectPtr to another object that is subclasses with a blueprint, then any references to instances of that blueprint will be cleared when you compile that blueprint. The references aren’t lost if you use normal pointers to reference the other objects, but those will be strong references. Since strong references will keep instances alive, that may not be desired.
Here’s a simple repro:
- Create a c++ class called AMyFirstActor and AMySecondActor.
- In AMyFirstActor make a UPROPERTY of a TWeakObjectPtr.
- Make a blueprint derived from AMySecondActor called MySecondBlueprint.
- Add an instance of AMyFirstActor and MySecondBlueprint to a level.
- Set the property created in step 2 on the AMyFirstActor instance, set it to the instanceof MySecondBlueprint.
- Compile the MySecondBlueprint.
- Notice the reference created in step 5 is cleared to “None”.
Expected:
TWeakObjectPtr references are not cleared when the objects referenced have their blueprints compiled.