Tanoda
pb_LayoutElementText.cs
Go to the documentation of this file.
1using UnityEngine;
2using UnityEngine.UI;
3using System.Collections;
4
5namespace GILES.Interface
6{
10 public class pb_LayoutElementText : LayoutElement
11 {
12 public bool expandWidth = true, expandHeight = false;
13 public Text text;
14 public float paddingWidth = 4f, paddingHeight = 4f;
15
16 public override float minWidth
17 {
18 get { return GetTextWidth(); }
19 }
20
21 public override float preferredWidth
22 {
23 get { return GetTextWidth(); }
24 }
25
26 public override float minHeight
27 {
28 get { return GetTextHeight(); }
29 }
30
31 public override float preferredHeight
32 {
33 get { return GetTextHeight(); }
34 }
35
36 float GetTextWidth()
37 {
38 if(text != null && expandWidth)
39 return text.preferredWidth + (paddingWidth * 2f);
40 else
41 return -1f;
42 }
43
44 float GetTextHeight()
45 {
46 if(text != null && expandHeight)
47 return text.preferredHeight + (paddingHeight * 2f);
48 else
49 return -1f;
50 }
51 }
52}