forked from TouchScript/TouchScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample.cs
More file actions
30 lines (24 loc) · 841 Bytes
/
Copy pathExample.cs
File metadata and controls
30 lines (24 loc) · 841 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using UnityEngine;
[ExecuteInEditMode]
public class Example : MonoBehaviour {
public string Text;
private GUIStyle style;
private Color color = new Color(0, 0, 0, .9f);
private void OnGUI()
{
if (style == null)
{
style = new GUIStyle(GUI.skin.label);
style.normal.background = new Texture2D(1, 1);
style.normal.background.SetPixel(0, 0, Color.black);
style.padding = new RectOffset(5, 5, 5, 5);
}
var c = GUI.backgroundColor;
GUI.backgroundColor = color;
var rect = GUI.skin.label.CalcSize(new GUIContent(Text));
GUILayout.BeginArea(new Rect(50, Screen.height - rect.y - 50, rect.x + 20, rect.y + 20));
GUILayout.Label(Text, style);
GUILayout.EndArea();
GUI.backgroundColor = c;
}
}