- Home /
 
GUI texture size doesn't match control set with the same size
Hello
I've imported a .png containing look of a button.I've set texture type to GUI and warp to clamp.The texture has 210x32 pixels. Then,I've created C# script: public class MainMenu : MonoBehaviour { public Texture2D aboutButton; public Texture2D optionsButton; public Texture2D helpButton;
     float menuButtonWidth = 210;
     float menuButtonHeight = 32;
 
  // Use this for initialization
  void Start ()
     {}
  
  // Update is called once per frame
  void Update () 
     {}
 
     void OnGUI()
     {
 
         GUI.Button(new Rect(20,20,menuButtonWidth,menuButtonHeight),optionsButton);
         GUI.Button(new Rect(20,62,menuButtonWidth,menuButtonHeight),helpButton);
         GUI.Button(new Rect(20,104,menuButtonWidth,menuButtonHeight),aboutButton);
     }
 }
 
               And my problem is that these button are to large,or the textures are shrinked. What causes my issue,and how to solve it?Help me please.
Answer by Seth-Bergman · Jul 27, 2012 at 12:18 PM
maybe try:
GUI.Button(new Rect(20,20,menuButtonWidth,menuButtonHeight),optionsButton,"label");
otherwise you probably want to create a gui skin and set border/padding to 0..
I've no idea why it works,but adding "l" solved the size issue.Thanks!
Your answer
 
             Follow this Question
Related Questions
OnGui Function help 1 Answer
Repeat fade in and out 1 Answer
Understanding GUISkin/GUIStyle BackgroundImage and Border 2 Answers
Aspect Ratio changes GUI Location Code in CSHARP 1 Answer
GUI button doesn't appear on Android 0 Answers