5 using System.Collections.Generic;
21 [Tooltip(
"A pixel to Unity unit conversion, Default: 2048x2048 pixels covers a 1x1 Unity Unit or default primitive size")]
22 public float BasePixelScale = 2048;
24 [Tooltip(
"The transform this object should be linked and aligned to")]
27 [Tooltip(
" The z-depth or size of this element using the pixel base size ratio")]
28 public float Depth = 20;
30 [Tooltip(
"The amount of pixel based distance between the top edge of the Anchor and this element's top edge")]
31 public float TopBuffer = 10;
33 [Tooltip(
"The amount of pixel based distance between the top edge of the Anchor and this element's right edge")]
34 public float RightBuffer = 10;
36 [Tooltip(
"The amount of pixel based distance between the left edge of the Anchor and this element's left edge")]
37 public float LeftBuffer = 10;
39 [Tooltip(
"The amount of pixel based distance between the top edge of the Anchor and this element's bottom edge")]
40 public float BottomBuffer = 10;
42 [Tooltip(
"The amount of pixel based distance to offset the position along the z axis")]
43 public float ZOffset = -5;
48 private void UpdatePosition()
50 float xOffset = (RightBuffer - LeftBuffer) / 2;
51 float yOffset = (TopBuffer - BottomBuffer) / 2;
53 Vector3 newPosition = AnchorTransform.localPosition + Vector3.right * (xOffset / BasePixelScale) + Vector3.down * (yOffset / BasePixelScale) + Vector3.forward * (ZOffset / BasePixelScale);
54 transform.localPosition = newPosition;
60 private void UpdateSize()
62 Vector3 newScale =
new Vector3((AnchorTransform.localScale.x * BasePixelScale - (RightBuffer + LeftBuffer)) / BasePixelScale, (AnchorTransform.localScale.y * BasePixelScale - (TopBuffer + BottomBuffer)) / BasePixelScale, Depth / BasePixelScale);
63 transform.localScale = newScale;
69 if (AnchorTransform != null)