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 /
This question was closed Jan 02, 2013 at 12:37 PM by goo-muffin for the following reason:

The question is answered, right answer was accepted

avatar image
1
Question by goo-muffin · Dec 28, 2012 at 07:17 PM · guibuttonsindex

CSS -> z-index, GUI -> ?

Hi!

Is there something like a z-index also in GUI? So that the Gui Button with the highest z-index is the one that is shown on top of all?

BTW: I know that it goes with the order of the buttons, but is there another way?

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

3 Replies

  • Sort: 
avatar image
1
Best Answer

Answer by Bunny83 · Dec 29, 2012 at 10:38 AM

You have to distinguish between things drawn in OnGUI and things drawn in a window callback. Like the others already explained the order for things drawn In OnGUI depends only on the execution order since unity uses an immediate mode. At the moment a line is executed it will be rendered on screen.

GUI.depth can be used to tell unity in with order you want different scripts be executed.

Additionally to that there are windows. Windows aren't drawn immediately when you call the Window function. Unity will store each window internally and specifies a separate render order which takes place after all OnGUI stuff is finished. Windows are always be drawn above the "normal" GUI. Which window is the top most can be controlled with:

  • GUI.BringWindowToFront

  • GUI.BringWindowToBack

  • GUI.FocusWindow

  • GUI.UnfocusWindow

Just read the window reference carefully. It doesn't cover everything but the most important things.

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 goo-muffin · Dec 31, 2012 at 12:18 PM 0
Share

thank you that was exactly what I was searching for! I just created a new Window and did it on the top and that worked fine :D

avatar image
1

Answer by Geo.Ego · Dec 28, 2012 at 07:57 PM

Sorry, it's strictly determined by draw order. If you want a GUI element to be drawn on top of another, you have to draw it afterwards.

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 goo-muffin · Dec 29, 2012 at 10:14 AM 0
Share

well I did but it doesn't do it anyway? $$anonymous$$aybe because of the window in front of it:

windowRect = GUI.Window (0, windowRect, Window, ""); if(draggedItem != 0){ GUI.DrawTexture(Rect(Input.mousePosition.x,Screen.height-Input.mousePosition.y,size.x - 5,size.y - 5), manager.textures[draggedItem-1], Scale$$anonymous$$ode.StretchToFill, true, 10.0f); }

avatar image
0

Answer by Itinerant · Dec 28, 2012 at 08:04 PM

There is slightly more to it than draw order, but not much. You can use http://docs.unity3d.com/Documentation/ScriptReference/GUI-depth.html

However, that's a by-script sort of thing. So if you have GUIs in two different scripts, you can stack them how you want. For general use, though...it's all about the draw order, just like Geo said.

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

Follow this Question

Answers Answers and Comments

11 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

Related Questions

DIALOGUE BRANCH CREATION? 1 Answer

How do I make a custom font for a GUI button? C# 1 Answer

Tutorials for 2D game GUI 2 Answers

Change variable in Mono from other script 1 Answer

I want to move my cube using GUI buttons? 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