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
0
Question by Scopus · Jan 31, 2014 at 08:34 PM · guibuttonsguitexture

Draw Button with GUITexture which looks like Unity button

Hey Guys,

I was wondering how unity draws buttons (if drawn in the OnGUI function). When I look into a GUI skin, the default button background is an image with only 12x12 pixels. I now want to use the same image with a GUITexture. But because the size is 12x12 pixels, the texture becomes ugly and pixelated if I increase the size of the GUITexture. So how Unity is able to draw a good looking button from this small image, no matter how big you want the button? And how can I do the same with a GUITexture?

Thanks for your help.

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by poncho · Jan 31, 2014 at 08:39 PM

you could use a 12x12 pixels to build a x*y pixels button, you could make a function to get the corner 4x4, the mids 4x4, 1x4 or 4x1 and the center 4x4 to resize in any texture size you need, some getpixels, and a local texture2d would do the trick, the corners would stay the same, but the mids and center will repeat the number required to close the gaps, just a little math here and there and you are done

Comment
Add comment · Show 2 · Share
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 Scopus · Feb 01, 2014 at 01:49 PM 0
Share

Thank you for your answer. Yesterday I tried it again by myself and I found a solution, very similar to yours. A GUITexture has the properties Left Border, Right Border, Top Border and Button Border. There you can define the pixels which will never be scaled. So I set every one of them to 5 and now it looks exactly like a normal button.

If someone want to do the same, here you can find the official skins of unity, including the texture for the button.

avatar image poncho · Feb 02, 2014 at 01:28 AM 0
Share

well, never thought about unity would help us out in that level, great thing though, I tried helping you and you helped me back, Thanks Scopus

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

19 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 avatar image

Related Questions

Reduce Draw call for Multiple GUI Textures with same Texture 1 Answer

2 Position GUI Texture Rocker Switch 0 Answers

How to control GUITextures within a single C# script? 1 Answer

GUI 2D Bounding Box 1 Answer

Move GUI elements. 0 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