addWith<T extends Component> method
Adds a new object below this one with component on it, and returns
the component, for a field: _sun = addWith(Light.sun()) where
add(GameObject(components: [Light.sun()])).get<Light>()! would. name, transform and layer are the new object's, and
components go on it after component, as a camera's rig:
addWith(VirtualCamera(), components: [Orbit(player)]).
Implementation
T addWith<T extends Component>(
T component, {
String? name,
Transform? transform,
Iterable<Component> components = const [],
int layer = 0,
}) {
add(GameObject(name: name, transform: transform, components: [component, ...components], layer: layer));
return component;
}