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 xxPillsxx · Aug 17, 2018 at 04:45 AM · editoreditor-scriptingeditorguieditor extensioneditor scripting

SceneView.onSceneGUIDelegate GUI sorting problem

I'm making some editor extensions and so far, I have a Non-MonoBehaviour (not editor) script (SceneViewEx) that adds some stuff to the scene view (using SceneView.onSceneGUIDelegate in the script's constructor) and a custom editor for a Mono-Behaviour script (ItemEditor) that also draws some stuff to the scene view (GUI.Button at the gameobject's position).

However, for the gameobjects, I'm not using OnSceneGUI because I want the buttons to always be visible, so instead I'm using OnDrawGizmos and again, use SceneView.onSceneGUIDelegate to draw the buttons (has to be OnSceneGUI for them to be interactable). The problem is that the buttons for the Item components are being drawn on top of the SceneViewEx's GUI elements. I've tried GUI.depth but it doesn't work at all. I suspect this is being caused by the Execution Order of the scripts, or to be more exact, the order of the delegate's listeners, however I can't set their Execution Order because they are not Mono-Behaviour scripts (I can set Item's order, but making it earliest or latest didn't change anything).

alt text

To sum up: SceneViewEx is a Non-MonoBehaviour script that uses SceneView.onSceneGUIDelegate to draw on Scene View GUI, ItemEditor is an editor script which also uses SceneView.onSceneGUIDelegate inside OnDrawGizmos to draw interactable buttons in the Scene View GUI even when object is not selected. ItemEditor's GUI is being drawn on top of SceneViewEx's GUI and I don't want that.

Is there anyway to make ItemEditor's GUI draw behind SceneViewEx's GUI, or make onSceneGUIDelegate execute ItemEditor's function first, then SceneViewEx's?

untitled.png (174.8 kB)
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
0
Best Answer

Answer by xxPillsxx · Aug 17, 2018 at 05:08 AM

Alright, after asking how to reorder the delegate's execution order, I ended up following that method. In the ItemEditor script, after adding to the onSceneGUIDelegate, I remove the SceneViewEx's OnGUIFunc then add it again, this ensures that SceneViewEx's will be executed last and thus drawn on top of everything else. Although this tank my editor performance quite a lot, it works.

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

129 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 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 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

Hint at Inspector variables that have tooltips 0 Answers

Better Unity Event UI 0 Answers

How can i create a pup-up menu like the one for choose the shader on materials in unity 2019? 1 Answer

Custom inspector difficulties creating a Box / Group like widget 1 Answer

Play Unity Editor from VSCode? 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