ContainerRuntime is a GraphicalUiElement-inheriting object used to organize and perform layout on a specific group of objects. Examples of when to use a container include:
Providing margins inside the screen or another container
Aligning or orienting children along a common position
Changing children layout types, such as stacking children horizontally inside a parent container which stacks its children vertically
To inject spacing between objects when using ratio width or height
ContainerRuntime instances have no visuals, so they cannot be directly observed in game.
To create a ContainerRuntime, instantiate it and add it to the managers as shown in the following code:
Containers are usually used as parents for other runtime objects. To add another runtime instance to a container, add it to the Children list as shown in the following code:
Notice that only the parent object needs to have its AddToManagers method called. Any child added to a parent which has been added to managers is automatically added as well. This membership is cascaded through all children, so if your project has a single root object, then only that root object needs to be added (or removed) from managers.
The following code shows a parent container added to managers. The child container and child text do not need to be added to managers: