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
0
Question by apomarinov1 · Jan 25, 2016 at 11:45 AM · guionguidraw order

OnGUI draw order issue

I have an editor window that draws a dynamic tree hierarchy, where each node is a GUI.Box, after that in the code I draw the connecting accordion lines. As you can see the lines are drawn in front of the tiles. This is happening in a single script. I moved the drawing of the tiles after the drawing of the lines, but it didnt work. I tried GUI.depth, didnt work.alt text

Edit: What Im doing in code is:

 foreach(allTiles) {
     if(something) {
         drawConnectinglines()
     }
     drawTileAndItsContent
 }
 

Now Itried seperating the tile draw and line draw in different loops:

    foreach(allTiles) {
         if(something) {
             drawConnectinglines()
         }
     }
     foreach(allTiles) {
         drawTileAndItsContent
     }

The result is that now the lines are behind the buttons in the tiles, but infront of them: alt text

2016-01-25-16-19-00-unity-mainunity-gar-fuze-gar-f.png (23.7 kB)
2016-01-25-11-59-40-unity-mainunity-gar-fuze-andro.png (30.8 kB)
Comment
Add comment · Show 2
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 Cherno · Jan 25, 2016 at 02:08 PM 0
Share
  1. GUI.depth only works between scripts, not inside the same script.

  2. If the buttons and tiles should be drawn later (over) the lines, call their drawing code after the line drawing code.

  3. Do you use EditorGUI functions for all the drawing?

avatar image apomarinov1 Cherno · Jan 25, 2016 at 02:39 PM 0
Share

$$anonymous$$y setup is: EditorGUILayout.BeginScrollView GUILayout.Box with size calculated from all tiles - makes the scrollview to actually "scroll" Tiles, Lines and buttons use GUI.box/button end scrollview

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by Garazbolg · Jan 25, 2016 at 02:07 PM

First of all : we need more information then that to help you. Second : changing the order should have done the trick but i can't tell why it didn't (not enough informations) Finally : i think you should draw every child of each branch before going to the next like this :

 Root
   |
   +----A
   |     |
   |     + ------A1
   |     |          |
   |     |          +-----A1a
   |     |          |
   |     |          +-----A1b
   |     |          |
   |     |          +-----A1c
   |     |
   |     +-------A2
   |     |          |
   |     |          +-----A2a
   |     |
   |     +-------A3
   |
   +----B
          |
          + ------B1
                      |
                      +-----B1a
                      |
                      +-----B1b



Like this you shouldn't have anything overlapping. And you can use recusivity to display that tree.

Hope it helps you, but if you want more you'll have to give us more to work with.

Comment
Add comment · Show 4 · 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 apomarinov1 · Jan 25, 2016 at 02:21 PM 0
Share

Ive updated my question, hope it makes it a little more clear.

avatar image Garazbolg apomarinov1 · Jan 25, 2016 at 02:34 PM 0
Share

Its better but your problem isn't really there. I think the problem is in the way you draw the lines, because shouldn't "Stats Summury" come from "Stats" ins$$anonymous$$d of "Robot" ?

If that's right then "Robot" should have only one child and the line should stop at point where it goes to "Build Robot"

$$anonymous$$aybe show your code ( the real one not some pseudo code) from drawConnectingLines() ? It would be way easier to spot what is wrong.

avatar image apomarinov1 Garazbolg · Jan 25, 2016 at 02:45 PM 0
Share

Oh dang, I got it. Yes you are right - stats summary and build robot are on the same level(indentation) and what I do is I draw from the last to the first tile on the level, which doesnt take into account if the tiles have different parent. I guess I should draw the line not to the first panel on the level but to the first panel with the same parent on the level. Thanks, well see if that works.

avatar image Bunny83 apomarinov1 · Jan 25, 2016 at 02:48 PM 0
Share

Uhm, no, ^^ it's not really clearer. It seems you messed up your line drawing. Some lines should have ended earlier. It seems your structure should look like this:

 $$anonymous$$ain $$anonymous$$enu
  |
  +--Robot
  |   |
  |   \--Build Robot
  |       |
  |       \--Build Robot Inventory
  |           |
  |           \--Build Robot Item Details
  |
  +--Stats
  |   |
  |   +--Stats Summary
  |   |
  |   +--Stats Statistics
  |   |
  |   +--Stats Achievements Select
  |   |   |
  |   |   \--Stats Achievement
  |   |
  |   \--Stats Ladder
  |       |
  |       \--Stats All Ladders
  |
  \--Social $$anonymous$$enu

It might go further down after "Social $$anonymous$$enu" but we don't see more than that. As you can see "Robot" has only one child object which is "Build Robot". So the vertical line that starts at "Robot" should end at "Build Robot". The same holds true for deeper childs as well.

We don't know how you draw those lines but you most likely have a logic error there.

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

48 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to display a set of guiText OnGUI 0 Answers

OnGUI() Resources 1 Answer

Is there a way to set a GUI.matrix that will be used by all OnGui() functions? 1 Answer

Drawing GUI rectangle uses negative y coordinate 1 Answer

How to draw a triangle with OnGUI from its sides and angles? 2 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