官术网_书友最值得收藏!

Anchor and Pivot Point

Every UI object has a set of Anchor Handles and a Pivot Point. These objects used together will help ensure that your UI is positioned appropriately and scales appropriately if the resolution or aspect ratio of your game changes.

The Anchor Handles are represented by four triangles in the form of an X, as shown in the following diagram:

The Anchors can be in a group together forming a single Anchor, as shown in the preceding diagram, or they can be split in to multiple Anchors, as follows:

The Anchors will always form a rectangle. So, the sides will always line up.

The Rect Transform has properties for Anchor Min and Anchor Max points. These represent the position of the Anchor Handles relative to the parent's Rect Transform, as percentages. So, for example, a 0 in an x value represents all the way to the left, and a 1 represents all the way to the right. You can see from the following screenshot how adjusting the x value will move it left and right, relative to the parent:

The Rect Transform has a Property for Anchor Presets and Anchors Min and Max Points. The Anchor represents the point at which the UI element is connected to its parent's Rect Transform:

As a Canvas has no parent, you'll see that the Anchor Preset is empty. This is true, regardless of the Canvas Render Mode chosen:

Click on the box holding representing the Anchor Presets icon will display a list of all the possible Anchor Presets.

If you click on one of the presets, it will move the anchors to the position displayed in the screenshot. You can also adjust the position and pivot point using the anchor preset. The images will change if you hold down Shift and/or Alt. Holding Shift will show positions for the pivot point represented by blue dots, holding Alt will show how the position will change, and holding both will show the pivot point and the position change.

主站蜘蛛池模板: 临高县| 武陟县| 塘沽区| 广灵县| 琼中| 舒兰市| 交城县| 黄龙县| 金秀| 新乐市| 论坛| 榆中县| 顺平县| 舒城县| 宝坻区| 大田县| 吴川市| 阜平县| 赤壁市| 镇康县| 韩城市| 维西| 麦盖提县| 乐清市| 阿巴嘎旗| 平果县| 丁青县| 安泽县| 梧州市| 内黄县| 舟曲县| 松潘县| 五家渠市| 准格尔旗| 白城市| 通化市| 台东县| 东乌珠穆沁旗| 昌都县| 乌鲁木齐县| 九台市|