What do you believe an UObject component should do? What’s the shared behavior you’re after, here?
You could easily build two UObject subclasses, UComposableObject
and UObjectComponent
. The UComposableObject
would have an array of Children
. The UObjectComponent
would have a Parent
UComposableObject
.
You coud then implement AttachComponent
and DetachComponent
functions, AttachComponent
would first detach the component from whatever other object, and then attach it to the given object.
Maybe you also add event dispatchers for on-attached and on-detached events.
This is 30 minutes of work. And then what? What benefit do you get from this composition, where there’s no other commonality between objects? It won’t replicate. It won’t have a transform hierarchy. It won’t really … solve any problem that I’m aware of.
What’s your use case, concretely?
Also, I’m a little confused by something in the question: What would using an UObject
as a module have to do with this? A module is a unit of code that gets separately loaded, like a DLL. Your typical C++ or blueprint library is a module (or part of a module); there’s no UObject
involved there. Do you mean “module” as in “component that gets attached?”