Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Simon Crowe · Aug 09, 2011 at 04:30 AM · efficiencygui.labeldifferencevsgui.drawtexture

What are the differences between GUI.Label(Used to draw a texture) and GUI.DrawTexture?

  1. Are there any differences between GUI.DrawTexture and GUI.Label, when used to draw a texture, other than the former offering more specialized options for drawing textures and the latter being stylable by default?

  2. In a situation where either would work, which would be a more efficient?

Comment
Add comment · Show 5
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 Simon Crowe · Aug 09, 2011 at 08:14 AM 0
Share

To my irritation, I discovered that drawing Images using GUI.Label and setting the rectangle dimensions to those of the image caused it to draw slightly improperly(filtering what made active, meaning that it wasn't at an ideal resolution). Setting the size of the rectangle higher solved the problem but I don't see why I should have to do this. GUI.DrawTexture doesn't seem to have this problem.

avatar image CHPedersen · Aug 09, 2011 at 08:22 AM 1
Share

I'm taking a guess here: I think that's because the label gets rendered with a GUIStyle that has a padding, i.e. some default space between its edges and the start of its contents. Take a look at http://unity3d.com/support/documentation/ScriptReference/GUIStyle-padding.html

So if the padding is non-zero, it's going to try to offset the texture you provide for it. Could that be what you're seeing?

avatar image Simon Crowe · Aug 09, 2011 at 08:50 AM 0
Share

Yes, the problem was caused by padding values of 3 for both top and bottom. Since I'm using the label element for other things, it makes sense for me to keep the padding values as they are and keep using GUI.DrawTexture for my textures.

Thank you, this partially answers my question, as the usefulness of having at least two ways of drawing a texture has been demonstrated.

avatar image Bluestrike · Jul 22, 2013 at 01:47 PM 0
Share

I would like to know the same, is one of them better for showing gui images? Is there perhaps a performance difference?

avatar image CHPedersen · Jul 22, 2013 at 01:54 PM 0
Share

It's possible there's some overhead associated with a Label vs just drawing the texture since the Label is a styled GUI component, and to get the same behavior as GUI.DrawTexture, you need to define a separate style with no padding for it. It also seems GUI.DrawTexture makes it pretty easy to use alpha blending with the background, I'm not sure how well GUI.Label would accomplish that, if at all.

For most intents and purposes I'd say they are interchangable, but without wanting to be definitive, GUI.DrawTexture feels a little more lightweight and lowlevel than the Label.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

IsPlaying vs isplaying 1 Answer

GUI.DrawTexture Error: BCE0023 0 Answers

GUILabel Text Overlapping After Updating 0 Answers

A'm I setting Up My GUI style Right? 1 Answer

Version of .sln file generated by unity3.5 1 Answer


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