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 ellolo · Feb 07, 2012 at 11:12 AM · editorwindowstate-machineplaymakergui.depth

Managing GUI.depth for drawing lines in EditorWindow

Hello,

I am currently doing a state-machine-like editor like The Spaghetti Machine or PlayMaker. Basically, I would like to display boxes and connect them together to represent a work-flow. In addition I would like to be able to edit interactively the content during play-mode.

I've started my work with EditorWindow where I display draggable windows (using GUI.DragWindow()) connected throw this code to draw Bezier curves.

My problem is related with the depth of the Bezier curves. If you take a look on the pictures for drawing lines, you will see that the Bezier curves remain behind the draggable windows, not in front.

I looked for solutions to cope with depth and found that I should use per-script settings for GUI.depth. But I do not see how I can achieve a drawing system like: one script draws the boxes, another one draws the Bezier curves. I thought that both the scripts could inherit from EditorWindow but I then don't know how to instantiate the script that is not launched by the Unity menu. I also thought that I could make the drawing-lines script inherit from MonoBehavior and tag it as ExecuteInEditMode but its OnGUI method is only called when the user interacted with the GUI. So, how can I manage the depth?! The Spaghetti Machine did an awesome work...

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

1 Reply

· Add your reply
  • Sort: 
avatar image
3

Answer by Zogg · Feb 18, 2012 at 03:23 AM

It's actually simpler than you thought: In OnGUI, what's drawn first is behind what's drawn second, except for windows drawn inside the BeginWindows-EndWindows block.

In the Spaghetti Machine, the lines are displayed behind the panels because they are drawn first. Boiled down to what is relevant to your question, the OnGUI method looks like this:

 public void OnGUI () 
 {
     // Display links - they appear behind the panels
     foreach( EditorLink link in maLinks )
     {    
         link.DrawLink();
     }
 
     // Display panels
     BeginWindows();
     for( int i = 0; i < maPanels.Length; i++ )
     {
         EditorPanel panel = maPanels[i] as EditorPanel;
         panel.mWindowRect = GUI.Window( iID, panel.mWindowRect, DoPanelWindow, strTitle );
     }
     EndWindows();
 }
 

I just made a quick test what happens when we draw the lines after EndWindows() :

 public void OnGUI () 
 {   
     // Display panels
     BeginWindows();
     for( int i = 0; i < maPanels.Length; i++ )
     {
         EditorPanel panel = maPanels[i] as EditorPanel;
         panel.mWindowRect = GUI.Window( iID, panel.mWindowRect, DoPanelWindow, strTitle );
     }
     EndWindows();

     // Display links - they appear in front of the panels
     foreach( EditorLink link in maLinks )
     {    
         link.DrawLink();
     }
 }

In this case, the lines are actually drawn in front of the panels.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Using Playmaker for a game-scope FSM 0 Answers

[Custom Editor Windows] Recreating Animator Controller Like Features 0 Answers

How do I stop new elements in a list/array from inheriting values from the last element? 1 Answer

Editor GUI Foldout header style customization 0 Answers

Scene Window goes grey in some scenes? 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