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 Teagan · Jul 29, 2010 at 08:19 AM · guitextdepthorderdrawtexture

drawing GUIText on top of GUI.DrawTexture

Does anyone know how to make a GUIText object in my scene draw on top of Textures I'm drawing in the "OnGUI" function with GUI.DrawTexture? The text is always behind currently.

Thank you.

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
0

Answer by Mike 3 · Jul 29, 2010 at 08:50 AM

Pretty much no way to do it

It'd be doable if you rendered your GUIText to a rendertexture, then rendered that in the GUI above the desired item, but that's unity pro only, and a pretty dodgy workaround

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 Teagan · Jul 29, 2010 at 05:36 PM 0
Share

Unfortunately its for iphone, so that wouldn't be practical. Is there an alternate to GUI.DrawTexture that could draw behind a GUIText object maybe? GUITexture perhapse? Thankyou.

avatar image Mike 3 · Jul 29, 2010 at 11:41 PM 0
Share

GUITexture would do it yes

avatar image
0

Answer by Teagan · Aug 01, 2010 at 01:17 AM

I actually ended up just making a really quick score display, as thats all I needed it for. It just requires images 0 through 9 in the Resources folder.

//score object. public class ScoreDisplay { public static Texture2D[] numberTextures;

 public ScoreDisplay() {
     numberTextures = new Texture2D[10];

     for (int x = 0; x < 10; x++) {
         numberTextures[x] = (Texture2D)Resources.Load(x + "");
     }
 }

 public void DrawText(Vector2 position, string score) {
     for (int i = 0; i < score.Length; i++) {
         GUI.DrawTexture(new Rect(position.x + 64 * i, position.y, 128, 128), numberTextures[int.Parse("" + score[i])]);
     }
 }

}

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 RGravity · Sep 20, 2012 at 10:05 AM

Render order for GUI elements is set by the z position of the transform. So in your case if you move the z position of the GUIText transform closer to the camera position than the other elements it will be drawn in front of them.

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 mbivol10 · Jun 17, 2015 at 03:20 AM

Yes simply like this:

 GUI.DrawTexture(new Rect(40,40,98,100), texture);
 GUI.Label(new Rect(68,72,80,20),"Text");
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

Drawing a GUI.DrawTexture call above GUI.Button in seperate scripts 0 Answers

How do I render triangles in a mesh in depth order? 1 Answer

Draw a GUIText behind a sprite 1 Answer

UI Button order 1 Answer

2D - How do you set the order in which game objects appear on screen? 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