As shown, after about 20 - 30 seconds, the instantiated object becomes None.
code:
why?
Please help me, think you
As shown, after about 20 - 30 seconds, the instantiated object becomes None.
code:
why?
Please help me, think you
That object is being garbage collected because your reference to it (your static variable) is not visible to the garbage collector (because it isn’t & can’t be a UPROPERTY). The most immediate solution to this would be calling AddToRoot on Util after you allocate it, but it has it’s downsides.
A better solution for this (and other singleton-like objects) are the subsystems. You can create them at a few different scopes. I haven’t used them myself yet so I can’t really help with any implementation details, but I know they’re out there and they would work for this type of access pattern.
Thank you very much