Skip to content

Instantly share code, notes, and snippets.

@hww
Forked from KDawg/gist:10537524
Created October 6, 2022 19:34
Show Gist options
  • Save hww/c41d1d9d492c30c0c80dc2ddde8ab50b to your computer and use it in GitHub Desktop.
Save hww/c41d1d9d492c30c0c80dc2ddde8ab50b 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