UPROPERTY needed for MenuInterface field?

Since MenuInterface will be a UObject, should the field be marked as a UPROPERTY so that Unreal’s garbage collection system can keep track of it?

In this particular case where we know we are using the GameInstance, I suppose that won’t ever get collected because of other things keeping it alive, but I’m wondering about recommendation for when that is not known.

I tried marking it with UPROPERTY and the compiler told me to use a TScriptInterface. I found the following article though where someone recommended just defining it as a UObject instead though:

UPROPERTY does garbage collect but also objects inherited from UObject also cleans up. So, while it might be clearer it is not necessary to define it as a UPROPERTY.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms