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
6
Question by AtomicMarine · Jan 07, 2011 at 10:12 PM · guitextureguitexture

How do I make certain GUI textures be in front of other GUI textures?

I have a health bar system and i need the health to be above the bar that it is in so that it appears as if the bar is slowly draining but for some reason it is behind I don't get this?

How do I make the health take preference over the bar in the GUI?

Comment
Add comment · Show 1
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 yoyo · Jan 08, 2011 at 12:08 AM 0
Share

(quick edit to add guitexture tag ;)

2 Replies

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

Answer by Mike 3 · Jan 07, 2011 at 10:14 PM

You can use the z position to set the rendering depth. The lower it is, the more in front it should be

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 AtomicMarine · Jan 07, 2011 at 10:20 PM 0
Share

tyvm didn't think it was so simple but it was thanks a ton

avatar image abhishakverma · Sep 07, 2013 at 11:52 AM 0
Share

that is awesome it work fine thanks a lot.

avatar image
7
Best Answer

Answer by yoyo · Jan 07, 2011 at 10:52 PM

If your GUI textures are drawn from different components, you can also set GUI.depth in the various OnGUI() methods ... to make Component1 draw over top of Component2:

Component1:

void OnGUI() { GUI.depth = 1; ... }

Component2:

void OnGUI() { GUI.depth = 2; ... }

Comment
Add comment · Show 6 · 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 AtomicMarine · Jan 07, 2011 at 10:55 PM 0
Share

luckily $$anonymous$$e are all from the same component :) But thanks this answer will be helpful to people who's GUI textures are from different components, nice answer :)

avatar image yoyo · Jan 07, 2011 at 11:13 PM 0
Share

In that case thanks for the upvote, but $$anonymous$$ike probably still deserves credit for the "right" answer :-)

avatar image Mike 3 · Jan 07, 2011 at 11:19 PM 0
Share

Indeed - this is for OnGUI, not for GUITextures. Guess it depends which GUI Texture we're talking about :D

avatar image AtomicMarine · Jan 07, 2011 at 11:39 PM 0
Share

credit has been given where credit is due >.<

avatar image yoyo · Jan 08, 2011 at 12:07 AM 2
Share

True, GUI.DrawTexture != GUITexture. Use GUI.depth for the one, and transform.z for the other. (Note that GUI.depth applies to everything drawn in your OnGUI routine.)

Show more comments

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

1 Person is following this question.

avatar image

Related Questions

GUI texture touch input problem 1 Answer

GUI.DrawTexture on GUI.Button press 1 Answer

GUI_TEXTURE PROBLEM! 2 Answers

movie as gui texture is pixelated? 1 Answer

NullReferenceException: Object reference not set to an instance of an object UnityEngine.GUI.DrawTexture 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