Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

editor window change size while docked?

Discussion in 'Immediate Mode GUI (IMGUI)' started by BloodMarked, Apr 30, 2022.

  1. BloodMarked

    BloodMarked

    Joined:
    Dec 11, 2013
    Posts:
    28
    so the basics of what I want to do, is enlarge a docking are, when the mouse is over it.

    I already managed to hook into the OnSceneGUI of the scene View, but when change the size of the scene view, it is automatically undocked.
    is there a way to change the size of a window, while keeping it docked? I was not able to find any code documentation relating to the docking areas of the unity editor at all.

    current code:
    Code (CSharp):
    1.  
    2. public static class SceneViewExtension
    3. {
    4.  
    5.     [InitializeOnLoadMethod]
    6.     private static void Init()
    7.     {
    8.         SceneView.duringSceneGui += OnSceneGUI;
    9.         EditorApplication.update += Update;
    10.     }
    11.     static void OnSceneGUI(SceneView sceneView)
    12.     {
    13.         Event e = Event.current;
    14.         if (e.type == EventType.MouseMove)
    15.         {
    16.             //enlarge the scene view when the mouse is over it
    17.             Vector2 mpos = GUIUtility.GUIToScreenPoint(e.mousePosition);
    18.             //Debug.Log(mpos);
    19.             Rect curPos = sceneView.position;
    20.             Rect newPos = new Rect(300, curPos.y, curPos.width, curPos.height);
    21.             sceneView.position = newPos; //this will undock the window :|
    22.             //EditorWindow.GetWindow<SceneView>().docked = true; //this is read only
    23.             bool mouseOverSceneView = EditorWindow.mouseOverWindow == sceneView;
    24.         } else if(e.type == EventType.KeyDown)
    25.         {
    26.             Debug.Log(e.keyCode);
    27.             if(e.keyCode == KeyCode.Space)
    28.                 sceneView.maximized = !sceneView.maximized;
    29.         }
    30.     }
    31.     static void Update()
    32.     {
    33.  
    34.     }
    35. }