GUI.BUTTON TEXTURED HOW TO
Hello! IMPORTANT: i dont want Ui4.6 and I dont want GUISKIN as a var, is there a way to upload texture as a button with that line?
I have that code:
if (GUI.Button(Rect(0,75,200,25), "Grass = "+grassAmount))
{
selectedBlock = grassBlock;
}
How can I change gui.button to mu own texture button in that code?
There are a lot of lines like this, well I prefer to stay with that code if its possible to make it as a texture. Please help~!
Answer by Spykill · Jul 30, 2016 at 10:54 PM
Use GUIContent: https://docs.unity3d.com/ScriptReference/GUIContent.html
For example,
if (GUI.Button(new Rect(0, 75, 200, 25), new GUIContent("Grass = " + grassAmount, texture)))
{
selectedBlock = grassBlock;
}
That said, I highly recommend switching to the new UI system. It makes designing UI ridiculously easy, and makes a ton prettier, as well as just being more flexible than the Immediate Mode GUI, which you are using. Just a suggestion :3
Hey! Thank You for that! It show me texture in "box button" i will find the way to show me only the texture ;)
I'm using the UI Unity in the same project but there are a looooot of scripts like that, and I'm so lazy to change everything to new UI for that moment :p
Your answer
Follow this Question
Related Questions
Help my gui code wont work i want screen to flash red 0 Answers
Rect.Contains not working correctly 0 Answers
New Unity 3d System 5.1.1 0 Answers
Pause Menu Display 1 Answer