Can I set a solid background for a GUI label?
I have a GUI Label in my program that comes up next to the mouse when it hovers over a certain collider. The colour of the object attached to the collider changes, so I would like to ensure that the label's text always has maximum visibility by setting a solid-coloured background for it. Is there a way to set a background texture or colour for labels?
Answer by Vega4Life · Dec 13, 2018 at 01:29 AM
Sure. Whatever script is using your OnGUI, reference an image. Then assign that image to the label. Just drag a texture to the image reference in the inspector on the script.
[SerializeField] public Texture image;
void OnGUI()
{
GUI.Label(new Rect(10, 10, 100, 100), image, "Label");
}
Your answer
Follow this Question
Related Questions
Unity WebCamTexture looks squashed in RawImage 0 Answers
How to import .blend file without loosing texture quality? 0 Answers
Change Texture 0 Answers
Texture file is all alpha when resizing 0 Answers
TerrainLayer at runtime 2 Answers