Skip to content

Instantly share code, notes, and snippets.

@KDawg
Created April 12, 2014 14:10
Show Gist options
  • Save KDawg/10537524 to your computer and use it in GitHub Desktop.
Save KDawg/10537524 to your computer and use it in GitHub Desktop.
Debug Unity3D OnGui Label Text With Background
// display a background texture banner
GUI.DrawTexture(new Rect(-30.0f, 384.0f, m_topScoreBanner.width, m_topScoreBanner.height), m_topScoreBanner);
Vector2 pivotPoint = new Vector2(Screen.width / 2, Screen.height / 2);
GUIStyle scoreStyle = new GUIStyle();
// DEBUG: create a background texture coloring the entire label background
Texture2D debugTex = new Texture2D(1,1);
debugTex.SetPixel(0,0,Color.grey);
debugTex.Apply();
scoreStyle.normal.background = debugTex;
scoreStyle.font = m_font;
scoreStyle.fontSize = 72;
scoreStyle.normal.textColor = Color.white;
scoreStyle.alignment = TextAnchor.UpperCenter;
GUIUtility.RotateAroundPivot(-10.0f, pivotPoint);
GUI.Label(new Rect(0.0f, 400.0f, 565.0f, 80.0f), m_topScoreLabel, scoreStyle);
GuiUtil.setMatrix();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment