c # – Recruitment Unity EditorWindow UI

When talking about the user interface, all the objects have a RectTransform instead of a Transform. One of its values ​​is the Anchors one. An anchor basically defines where the child is "connected" in relation to his father. Each object has 2 anchors, Min (for the lower left corner) and Max (for the upper right). Their values ​​go from 0 to 1, which means the percentage of the width / height of the screen.

If, for example, you have established both anchors like this:

anchorMin.x = 0.1;
anchorMax.x = 0.9;

anchorMin.y = 0.1;
anchorMax.y = 0.9;

And the RectTransformThe positions are all 0, then all edges of that object will be 10% of the edge of the screen, regardless of the size of the screen (the object basically extends from 10% to 90% of the screen size).

Note that if both X or Y Both anchors have the same value, the Inspector changes and gives you a new "width" or "height" field, which you can use to give your element a specific size. So with this example:

anchorMin.x = 0.1;
anchorMax.x = 0.9;

anchorMin.y = 0.5;
anchorMax.y = 0.5;

This object now stretches only horizontally from 10% to 90% of the screen space, and is also anchored vertically in the center of the screen, but at a single point. This means that you can give it its own height (for example, 100px) and the object will now stretch to fit the screen horizontally, while remaining at a height of 100px.

See also, Unit: Basic layout and Unit: User interface design for multiple resolutions