Children
Last updated
Was this helpful?
Last updated
Was this helpful?
The Children collection contains the direct descend children of the GraphicalUiElement. An instance's children will report the instance as their parent.
Note that Screen GraphicalUiElements have null
for Children. The reason is because Screen GraphicalUiElements do not have a position or size - they are merely containers for children without providing any layout information. Therefore, to access the items that a Screen contains, see the ContainedElements
property.
If a GraphicalUiElement is loaded in a game project, its Children property contains the direct children as established in Gum.
For example, consider a component with six children named ColoredRectangleInstance, ColoredRectangleInstance1, ... , ColoredRectangleInstance5:
If using code generation, these could be accessed by their names. If not using code generation, or if you need to access each item by index, then the component's Children property provides access.
For example, the following code could be used to set the children width:
Of course, if you know the type of the children, you can cast the child to its specific type. Be careful doing this, as you may end up with an invalid cast exception.
For example, the following code could be used to edit the children as ColoredRectangleRuntimes: