Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    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. Let us know a bit about your interests, and if you'd like to become more directly involved. Take our survey!
    Dismiss Notice
  4. Don't miss out on the Unite LA Keynote for the latest information from Unity! Set a reminder!
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  6. Want to see the most recent patch releases? Take a peek at the patch release page.
    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:
    179