Hello Louis!
First, just about your example:
I’m not sure if I’m right, but based on my test,
UPROPERTY()
TArray<TSharedRef<UObject>> ActiveObjects;
Will cause a UHT error:
error : Unable to find ‘class’, ‘delegate’, ‘enum’, or ‘struct’ with name ‘TSharedRef’
I don’t think I can use TSharedRef for UObjects. Although I know how to use TWeakObjectPtr. And so it is impossible to use as a property class in blueprints.
I think I need to recall the design targets, although these are hard to achieve all, so ‘it is impossible’ is also an acceptable answer:
- We need to unify the reference to both pooled and non-pooled objects. A UPROPERTY-marked pointer is OK and used as an example, but if there is another solution please let me know.
- We need to null out the pointers when recycle a pooled object, just like the UObject GC system did.
I can totally understand the reason that you recommend the handle struct solution. To be honest, as a programmer I agree with you. And I can design a handle wrapper based pool system so let’s just temporally skip this way.
To let you can get why we prefer a unified reference system, let’s image our designer are creating a BP, they need a way to save a reference to an Actor.
> ‘You need to check if this actor is pooled or not, and prepare two member variables to store the right one’
I don’t think our designers are like this kind of annoying rule.
That’s why I’m thinking about re-use the GC’s null pointer logic. So my question becomes: can you tell me some functions to check as a start point?
I think the function I’m looking for is:
- Give one UObject
- Tell me all the UPROPERTY-marked pointer properties
- Set these to nullptr
Really thanks for all your help!
Luo
[Attachment Removed]