-
Notifications
You must be signed in to change notification settings - Fork 14
Anchoring
UGUIDOTS does not use Unity's Transform system. Instead it uses its own transform components. These components
store position and scaling data as float2
instead of float3. To get the position data, you can grab the ScreenSpace
component and LocalSpace
component for world and local space respectively.
Both the ScreenSpace
components and LocalSpace
components stoe the Translation and Scale, but not the Rotation
of the element.
Rotation is not supported because for most intensive purposes, you can defer rotation to a shader via vertex animations.
When the screen resolution changes, each position of a UI element is recalculated to reposition itself relative to its parent's position. This allows anchoring to remain consistent to a relative position regardless of the screen size. For example, if you anchor an image to the top right corner with 100px away from the top and bottom at a resolution of 1920 x 1080. When you scale down to 1366x768, the image will still remain in the top right corner of the screen.
This has been implemented to try and recreate Unity's Anchoring System, although this is entirely up to feature parity with Unity's implementation.
While UGUIDOTS recursively rebuilds the transform data, this does not work well with negative scale. Negative scale also affects the positions of elements in UGUI, which in turrn can affect the mesh's vertices when elements are recalculated.