Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by FreetimeCoder · Aug 15, 2013 at 10:15 AM · guitexturebuttonarea

GUILayout.Button scales texture wrong

Hi,

sorry if this was already asked but I did not find anything.

I am trying to convert my gui into using the GUILayout class, however the textured button behaves differently.

This is the code:

 void OnGUI () {
     GUILayout.BeginArea(new Rect(0,0,128,128));
         GUILayout.Button(btnTexture);
     GUILayout.EndArea();
 
     GUI.Button(new Rect(128,0,128,128), btnTexture);
 }

In theory both buttons should look the same, however this is the result:

alt text

The button starts acting up as soon as its size is smaller than the texture to draw. Is there a way to fix this?

greetings

buttons.png (3.8 kB)
Comment
Add comment · Show 7
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Bunny83 · Aug 15, 2013 at 10:23 AM 0
Share

What size does your btnTexture has? Should that texture be a button background? If so why don't you use a gui skin?

avatar image FreetimeCoder · Aug 15, 2013 at 10:29 AM 0
Share

512x256, I know that this is way too big, but this is a general test. While this button won't be an image button I have others that will, so I cannot use a skin for that.

avatar image FreetimeCoder · Aug 18, 2013 at 04:13 PM 0
Share

I have now tried various button dimensions with texture dimensions. The problem seems to be that the button's height is always the height of the texture no matter how small or big it is scaled inside the button.

The same problem occurs when I use a selection grid.

avatar image Benproductions1 · Aug 19, 2013 at 08:04 AM 0
Share

Take a look at GUILayoutOptions.

Also note that GUILayout is always slower than plain GUI, so if you have the interface you like using GUI please don't convert it to GUILayout

avatar image FreetimeCoder · Aug 26, 2013 at 03:23 PM 0
Share

I tried them and while they do restrict the button's size they have no effect on the scaling issue.

I have an interface yes, but it does not ajdust like it would with the layout. Oh well, I guess I will have to program some sort of manager myself.

greetings

Show more comments

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

18 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

GUI.button Texture shows up in Unity but doesn't show on android device. 1 Answer

GuiTexture (Touch button) unfollow camera! 1 Answer

Change button texture when its clicked 1 Answer

Slice background texture for OnGUI button 0 Answers

Empty spaces in buttons are detected by mouse 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges