14 private enum ScaleModeEnum
21 private Transform cornerTopLeft = null;
23 private Transform cornerTopRight = null;
25 private Transform cornerBotRight = null;
27 private Transform cornerBotLeft = null;
30 private float cornerScale = 1f;
32 private ScaleModeEnum scaleMode = ScaleModeEnum.World;
42 Vector3 localContentSize = toolTip.LocalContentSize;
43 localContentSize.z = 1;
45 localContentSize *= 0.5f;
46 Vector3 localContentOffset = toolTip.LocalContentOffset;
48 Vector3 topLeft =
new Vector3(-localContentSize.x + localContentOffset.x, localContentSize.y + localContentOffset.y, localContentOffset.x);
49 Vector3 topRight =
new Vector3(localContentSize.x + localContentOffset.x, localContentSize.y + localContentOffset.y, localContentOffset.x);
50 Vector3 botRight =
new Vector3(localContentSize.x + localContentOffset.x, -localContentSize.y + localContentOffset.y, localContentOffset.x);
51 Vector3 botLeft =
new Vector3(-localContentSize.x + localContentOffset.x, -localContentSize.y + localContentOffset.y, localContentOffset.x);
52 if (cornerTopLeft != null)
54 cornerTopLeft.localPosition = topLeft;
57 if (cornerTopRight != null)
59 cornerTopRight.localPosition = topRight;
62 if (cornerBotRight != null)
64 cornerBotRight.localPosition = botRight;
67 if (cornerBotLeft != null)
69 cornerBotLeft.localPosition = botLeft;
73 Vector3 globalScale = Vector3.one;
76 case ScaleModeEnum.World:
77 Vector3 lossyScale = toolTip.ContentParentTransform.lossyScale;
78 globalScale.x /= lossyScale.x;
79 globalScale.y /= lossyScale.y;
80 globalScale.z /= lossyScale.z;
83 case ScaleModeEnum.Local:
84 Vector3 localScale = cornerTopLeft.lossyScale;
85 float smallestDimension = Mathf.Min(Mathf.Min(globalScale.x, globalScale.y), globalScale.z);
86 globalScale = Vector3.one * smallestDimension;
90 throw new System.ArgumentOutOfRangeException(
"ScaleMode not set to valid enum value.");
93 if (cornerTopLeft != null)
95 cornerTopLeft.localScale = globalScale * cornerScale;
98 if (cornerTopRight != null)
100 cornerTopRight.localScale = globalScale * cornerScale;
103 if (cornerBotRight != null)
105 cornerBotRight.localScale = globalScale * cornerScale;
108 if (cornerBotLeft != null)
110 cornerBotLeft.localScale = globalScale * cornerScale;
114 private void OnDrawGizmos()
116 if (Application.isPlaying)