A game about forced loneliness, made by TACStudios
1using UnityEngine;
2
3namespace UnityEditor.Timeline
4{
5 class Tooltip
6 {
7 public GUIStyle style { get; set; }
8
9 public string text { get; set; }
10
11 GUIStyle m_Font;
12
13 public GUIStyle font
14 {
15 get
16 {
17 if (m_Font != null)
18 return m_Font;
19
20 if (style != null)
21 return style;
22
23 // Default Font.
24 m_Font = new GUIStyle();
25 m_Font.font = EditorStyles.label.font;
26
27 return m_Font;
28 }
29 set { m_Font = value; }
30 }
31
32 float m_Pad = 4.0f;
33
34 public float pad
35 {
36 get { return m_Pad; }
37 set { m_Pad = value; }
38 }
39
40 GUIContent m_TextContent;
41
42 GUIContent textContent
43 {
44 get
45 {
46 if (m_TextContent == null)
47 m_TextContent = new GUIContent();
48
49 m_TextContent.text = text;
50
51 return m_TextContent;
52 }
53 }
54
55 Color m_ForeColor = Color.white;
56
57 public Color foreColor
58 {
59 get { return m_ForeColor; }
60 set { m_ForeColor = value; }
61 }
62
63 Rect m_Bounds;
64
65 public Rect bounds
66 {
67 get
68 {
69 var size = font.CalcSize(textContent);
70 m_Bounds.width = size.x + (2.0f * pad);
71 m_Bounds.height = size.y + 2.0f;
72
73 return m_Bounds;
74 }
75
76 set { m_Bounds = value; }
77 }
78
79 public Tooltip(GUIStyle theStyle, GUIStyle font)
80 {
81 style = theStyle;
82 m_Font = font;
83 }
84
85 public Tooltip()
86 {
87 style = null;
88 m_Font = null;
89 }
90
91 public void Draw()
92 {
93 if (string.IsNullOrEmpty(text))
94 return;
95
96 if (style != null)
97 {
98 using (new GUIColorOverride(DirectorStyles.Instance.customSkin.colorTooltipBackground))
99 GUI.Label(bounds, GUIContent.none, style);
100 }
101
102 var textBounds = bounds;
103 textBounds.x += pad;
104 textBounds.width -= pad;
105
106 using (new GUIColorOverride(foreColor))
107 GUI.Label(textBounds, textContent, font);
108 }
109 }
110}