Search Unity

  1. Unity 2019.1 beta is now available.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We're looking for insight from anyone who has experience with game testing to help us better Unity. Take our survey here. If chosen to participate you'll be entered into a sweepstake to win an Amazon gift card.
    Dismiss Notice
  4. On February 28th the Feedback website will shut down and be redirected to the Unity forums. See the full post for more information.
    Dismiss Notice
  5. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  6. Unity 2018.3 is now released.
    Dismiss Notice
  7. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

Draw native OnSceneGUI options for custom EditorWindow

Discussion in 'Extensions & OnGUI' started by ReneBaumgartner, Jul 23, 2014.

  1. ReneBaumgartner

    ReneBaumgartner

    Joined:
    May 3, 2014
    Posts:
    9
    Hello there!

    I want to create a native options menu inside the SceneView (have a look at the attached image) from my custom EditorWindow.

    OnSceneOptions.png

    I already know that i can draw GUI controls inside the SceneView with this code:

    Code (CSharp):
    1. #if UNITY_EDITOR
    2.  
    3. using UnityEngine;
    4. using UnityEditor;
    5.  
    6. public class MyCustomEditorWindow : EditorWindow
    7. {      
    8.     void OnEnable()
    9.     {
    10.         SceneView.onSceneGUIDelegate += this.OnSceneGUI;
    11.     }
    12.  
    13.     void OnDisable()
    14.     {
    15.         SceneView.onSceneGUIDelegate -= this.OnSceneGUI;
    16.     }
    17.  
    18.     void OnSceneGUI( SceneView sceneView )
    19.     {
    20.         if( SceneView.lastActiveSceneView != null )
    21.         {
    22.             Handles.BeginGUI();
    23.  
    24.             // Draw something here using GUI or GUILayout...
    25.      
    26.             Handles.EndGUI();
    27.             SceneView.lastActiveSceneView.Repaint();
    28.         }
    29.     }
    30. }
    31. #endif
    Now I want to achieve the same behaviour as the native OnScene options - like those from the "Navigation" or "Occlusion Culling" EditorWindows or from an inspected camera (the little preview in the bottom right).

    When you open/close those tabs, the options arrange themselves properly so nothing gets occluded.

    In addition it would be nice to also style them properly - maybe using the undocumented styles from the default editor skin.. But that's the second step ;)

    Any thoughts on this? Thank you in advance!

    Best,
    Rene
     
    sandolkakos likes this.
  2. Esteem

    Esteem

    Joined:
    May 26, 2016
    Posts:
    27
    necrobump?
     
  3. sandolkakos

    sandolkakos

    Joined:
    Jun 3, 2009
    Posts:
    184