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 Auzette · Nov 17, 2010 at 02:07 AM · guigraphicsdrawtexture

GUI.DrawTexture versus Graphics.DrawTexture

We've been using GUI.DrawTexture for our UI system, but a question was brought up as to why we don't simply use Graphics.DrawTexture instead.

Is there any drawback to always using Graphics.DrawTexture instead of GUI.DrawTexture? It seems that the former provides everything the latter does, but with the added bonus of being able to utilize materials.

THanks.

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

4 Replies

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

Answer by denewbie · Nov 17, 2010 at 08:31 AM

I've never really compared them side by side before but based on how I've used them I cant tell much of a difference at run time. And I m talking about calling the textures about more than 50 times withing each OnGUI segment because I've to dynamically generate 2D UI data. I've come to like drawTexture a little better because I've been using "GUI." stuff so if make my code and thought process more consistance looking but I don't really see why the other should be deemed as inferior.

Comment
Add comment · Show 1 · 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 IronMike · Dec 07, 2010 at 07:38 AM 0
Share

@denewbie Can you help me on this thread? I want to use DrawTexture and can't get it to work: http://answers.unity3d.com/questions/30582/gui-drawtexture-not-working

avatar image
1

Answer by spolglase · Feb 22, 2012 at 10:00 PM

One thing I will say about Graphics.DrawTexture() is that it allows you to write your own shaders for your 2D elements. The way to do this is to pass in a material to you Graphics.DrawTexture() call that has an attached custom shader. This can be handy in any number of ways if you want to use shaders in the 2D world.

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

Answer by JoeStrout · Feb 27, 2011 at 05:07 PM

The main difference I've found is that Graphics.DrawTexture allows you to specify a source rect (in texture coordinates, 0-1 in each axis), whereas GUI.DrawTexture can only draw the entire texture map. That makes the latter less useful for constructing any nontrivial GUI.

The other difference, I think, is that GUI.DrawTexture is smart about not drawing for event types other than EventType.Repaint, and Graphics.DrawTexture is not. See this thread for more details on this gotcha.

Comment
Add comment · Show 1 · 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 BilboX · Feb 06, 2015 at 06:00 PM 0
Share

GUI.DrawTextureWithTexCoords does.

avatar image
0

Answer by VoidX_HUN · Jul 25, 2015 at 01:46 AM

GUI.DrawTexture is significantly faster, tested on a single texture drawn 1920 times, it performed 50% better.

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

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

2 People are following this question.

avatar image avatar image

Related Questions

Graphics.DrawTexture drawing in both 2d and 3d?!? 2 Answers

Unity3D texture2d error help 0 Answers

Material is blending with background problem 0 Answers

GUI Rotation and Depth problem 1 Answer

How to cut image horizontally using DrawTextureWithTexCoords? 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