- Home /
Making texture cover whole button
How do you make a 2D Texture cover the whole button? When I write
GUI.Button (Rect (0,0,50,50),texture);
the texture turns out like this:
How do I make it so that the texture covers the whole button?
Answer by Swaminathan · Mar 20, 2014 at 07:15 AM
Use GUIStyle for applying Texture to a button.
Instead of using Texture2D try using GUIStyle and add your custom Style.
Sample code:
var style_1:GUIStyle;
GUI.Button(Rect (0,0,100,100),"",style_1);
then click and drag your custom texture to the button.
If u have doubt follow this link:
http://docs.unity3d.com/Documentation/Components/class-GUIStyle.html
hope this may help you.
Your answer
Follow this Question
Related Questions
Assiging an Image to a Button 1 Answer
Empty spaces in buttons are detected by mouse 2 Answers
Change GUI.Button Texture on runtime 1 Answer
GUI.DrawTexture on GUI.Button press 1 Answer
OnGUI button created by a foreach loop 4 Answers