5 using System.Collections.Generic;
28 [Tooltip(
"The RectTransform that will drive the size and position of this object")]
31 [Tooltip(
"The pixel ratio conversion to Unity Units or scale")]
32 public float ScaleFactor = 2048;
34 [Tooltip(
"Add depth, a value RectTransforms do not support at this time")]
35 public float Depth = 10;
37 [Tooltip(
"The x and y margins")]
40 private RectTransform mRectTransform;
47 if (ParentRectTransform == null)
49 ParentRectTransform = transform.parent.GetComponent<RectTransform>();
52 if (ParentRectTransform == null)
54 Debug.LogError(
"The parent of " + name +
"does not have a RectTransform!");
57 mRectTransform = GetComponent<RectTransform>();
63 private void UpdateScale()
65 if (ParentRectTransform != null)
67 if (mRectTransform == null)
69 transform.localScale =
new Vector3((ParentRectTransform.rect.width - EdgeOffset.x) / ScaleFactor, (ParentRectTransform.rect.height - EdgeOffset.y) / ScaleFactor, Depth / ScaleFactor);
73 mRectTransform.sizeDelta =
new Vector2(ParentRectTransform.rect.width - EdgeOffset.x, ParentRectTransform.rect.height - EdgeOffset.y);