How to move UPROPERTY fields into a sub-object?

Say I have a giant class, “MyGame”, with way too many fields, and it needs a refactor. Let’s say I see a group of related fields and I think to myself, “let’s combine those fields into a single object.” Imagine something like this:

`
BEFORE:
class MyGame
{
… etc …
UPROPERTY()
TArray<AActor *> PinballActors;
TMap<int64, int> PinballIndex;
TMap<int, FColor> PinballColorTable;
… etc …
}

AFTER:
class MyGame
{
… etc …
FPinballManager PinballManager;
… etc …
}
`

Now, here’s my question: field PinballActors above is a TArray of Actor pointers, and is a UPROPERTY, and therefore, the garbage collector can find it, which is good. When I move it inside the PinballManager, it will still need to be “findable” by the garbage collector. My question is: do I have to make PinballManager a UObject in order for it to contain UPROPERTY fields? Should it be a UObject?

Ensure that the Pinball manager is a UObject (or derived in some way like an actor or actor component) marked with the UCLASS macro. Any field within will be “findable” to the engine so long as it has the UPROPERTY macro.