Parent
Last updated
Last updated
The Parent
variable allows UI elements to be positioned and sized according to other UI elements. Parenting hierarchies can go many levels deep and the parent/child relationship can be visualized by the white line connecting the parent to the child when the child is selected.
Parents control control the position of their children. Parents can also control the size of their objects depending on the child's Width Units
and Height Units
.
For example, if a parent is moved, its children move along with it. For more information on positioning children, see the X Units and Y Units pages.
Children can also be sized according to their parents. For more information on sizing children according to their parent, see the Width Units and Height Units pages.
Children can be placed outside of their parent's bounds. In the simplest case, a child can be dragged outside of its parent's bounds in the editor.
Children outside of their parent's bounds still follow all of the same rules for sizing and positioning, but there are some important things to keep in mind.
Children placed outside of a parent do not affect the parent's effective width or height. Any unit value that depends on children or parents only considers the immediate child or parent and does not look at sizes beyond the immediate relationship.
For example if a parent has 100 effective width, and its child is given an X
of 200, the parent's effective width remains 100 (assuming the parent does not size itself according to its children). This is important when other children are sized or positioned according to the parent's width.
The following animation shows three instances:
A parent container
A blue rectangle which is sized according to the parent rectangle
A yellow rectangle which is moved outside of the bounds of its parent
Notice that when the parent resizes the blue rectangle is also resized, but when the yellow rectangle is moved outside of the parent bounds, the parent and blue rectangle are not resized.
Children outside of bounds may not respond to click events unless the parent is explicitly checking for click events outside of its bounds. This is a property which is set at runtime. For more information see the RaiseChildrenEventsOutsideOfBounds page.
To change Parent
in the Project tab:
Select a child
Drag+drop the child onto the desired parent
The child can be detached from its Parent
by drag+dropping it onto the Component.
Drag+dropping onto a parent may set the Parent
property to an instance inside of the parent's Component type sets its Default Child Container value. For more information see the Default Child Container page.
To set Parent by name:
Select the desired child
Change the Parent
property to the desired parent: