Skip to content

User Interface

Dane Sherman edited this page Dec 18, 2018 · 3 revisions

In order to get collected items to easily enter/exit the inventory, utilize the same background fade on UI and world objects, and maintain a consistent pixel size I decided to write my own UI anchors that could be utilized as child objects of the Main Camera.

UI Anchors

Anchors

enum Anchor { topLeft, topCenter, topRight, middleLeft, middleCenter, middleRight, bottomLeft, bottomCenter, bottomRight } The standard anchor positions that any UI element should be able to achor to

Fields

Anchor anchor place on the screen this element is anchored to

Vector2 offset offset from the anchor point

bool snapToPixel when true, causes the element to snap to a pixel-perfect position (usually true)

Set Position

Called from both Awake and a Set Method. Calculates where the UI element should be.

Flower Check out a Free Demo of the game on my personal website. (Updated Frequently)

Clone this wiki locally