39 [SerializeField]
private Align m_Align =
Align.TopCenter;
40 [SerializeField]
private float m_Left;
41 [SerializeField]
private float m_Right;
42 [SerializeField]
private float m_Top;
43 [SerializeField]
private float m_Bottom;
45 private TextAnchor m_TextAlignment;
47 private TextAlignmentOptions m_TMPTextAlignment;
49 private Vector2 m_AnchorMin;
50 private Vector2 m_AnchorMax;
51 private Vector2 m_Pivot;
58 get {
return m_Align; }
59 set {
if (PropertyUtil.SetStruct(ref m_Align, value)) { SetComponentDirty(); UpdateAlign(); } }
67 get {
return m_Left; }
68 set {
if (PropertyUtil.SetStruct(ref m_Left, value)) { SetComponentDirty(); UpdateAlign(); } }
76 get {
return m_Right; }
77 set {
if (PropertyUtil.SetStruct(ref m_Right, value)) { SetComponentDirty(); UpdateAlign(); } }
86 set {
if (PropertyUtil.SetStruct(ref m_Top, value)) { SetComponentDirty(); UpdateAlign(); } }
94 get {
return m_Bottom; }
95 set {
if (PropertyUtil.SetStruct(ref m_Bottom, value)) { SetComponentDirty(); UpdateAlign(); } }
106 public TextAlignmentOptions runtimeTMPTextAlignment {
get {
return m_TMPTextAlignment; } }
142 public static Location defaultRight
146 return new Location()
157 public static Location defaultTop
161 return new Location()
172 public static Location defaultBottom
176 return new Location()
187 private void UpdateAlign()
191 case Align.BottomCenter:
192 m_TextAlignment = TextAnchor.LowerCenter;
194 m_TMPTextAlignment = TextAlignmentOptions.Bottom;
196 m_AnchorMin =
new Vector2(0.5f, 0);
197 m_AnchorMax =
new Vector2(0.5f, 0);
198 m_Pivot =
new Vector2(0.5f, 0);
200 case Align.BottomLeft:
201 m_TextAlignment = TextAnchor.LowerLeft;
203 m_TMPTextAlignment = TextAlignmentOptions.BottomLeft;
205 m_AnchorMin =
new Vector2(0, 0);
206 m_AnchorMax =
new Vector2(0, 0);
207 m_Pivot =
new Vector2(0, 0);
209 case Align.BottomRight:
210 m_TextAlignment = TextAnchor.LowerRight;
212 m_TMPTextAlignment = TextAlignmentOptions.BottomRight;
214 m_AnchorMin =
new Vector2(1, 0);
215 m_AnchorMax =
new Vector2(1, 0);
216 m_Pivot =
new Vector2(1, 0);
219 m_TextAlignment = TextAnchor.MiddleCenter;
221 m_TMPTextAlignment = TextAlignmentOptions.Center;
223 m_AnchorMin =
new Vector2(0.5f, 0.5f);
224 m_AnchorMax =
new Vector2(0.5f, 0.5f);
225 m_Pivot =
new Vector2(0.5f, 0.5f);
227 case Align.CenterLeft:
228 m_TextAlignment = TextAnchor.MiddleLeft;
230 m_TMPTextAlignment = TextAlignmentOptions.Left;
232 m_AnchorMin =
new Vector2(0, 0.5f);
233 m_AnchorMax =
new Vector2(0, 0.5f);
234 m_Pivot =
new Vector2(0, 0.5f);
236 case Align.CenterRight:
237 m_TextAlignment = TextAnchor.MiddleRight;
239 m_TMPTextAlignment = TextAlignmentOptions.Right;
241 m_AnchorMin =
new Vector2(1, 0.5f);
242 m_AnchorMax =
new Vector2(1, 0.5f);
243 m_Pivot =
new Vector2(1, 0.5f);
245 case Align.TopCenter:
246 m_TextAlignment = TextAnchor.UpperCenter;
248 m_TMPTextAlignment = TextAlignmentOptions.Top;
250 m_AnchorMin =
new Vector2(0.5f, 1);
251 m_AnchorMax =
new Vector2(0.5f, 1);
252 m_Pivot =
new Vector2(0.5f, 1);
255 m_TextAlignment = TextAnchor.UpperLeft;
257 m_TMPTextAlignment = TextAlignmentOptions.TopLeft;
259 m_AnchorMin =
new Vector2(0, 1);
260 m_AnchorMax =
new Vector2(0, 1);
261 m_Pivot =
new Vector2(0, 1);
264 m_TextAlignment = TextAnchor.UpperRight;
266 m_TMPTextAlignment = TextAlignmentOptions.TopRight;
268 m_AnchorMin =
new Vector2(1, 1);
269 m_AnchorMax =
new Vector2(1, 1);
270 m_Pivot =
new Vector2(1, 1);
287 case Align.BottomCenter:
288 return new Vector3(chartWidth / 2,
bottom);
289 case Align.BottomLeft:
291 case Align.BottomRight:
294 return new Vector3(chartWidth / 2, chartHeight / 2);
295 case Align.CenterLeft:
296 return new Vector3(
left, chartHeight / 2);
297 case Align.CenterRight:
298 return new Vector3(chartWidth -
right, chartHeight / 2);
299 case Align.TopCenter:
300 return new Vector3(chartWidth / 2, chartHeight -
top);
302 return new Vector3(
left, chartHeight -
top);
304 return new Vector3(chartWidth -
right, chartHeight -
top);