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. Dismiss Notice

Constraining EditorWindow size

Discussion in 'Immediate Mode GUI (IMGUI)' started by User340, Apr 22, 2011.

  1. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    How do you set the minimum size a custom EditorWindow can be? I've tried so many different things, and just can't figure it out...

    I've tried stuff like this:

    Code (csharp):
    1. void Update or OnGUI () {
    2.    if (position.width < 50)
    3.       position = new Rect (position.x, position.y, 50, position.height);
    4. }
    5.  
    This didn't work well at all. It just made my window act all glitchy.

    For a great example of what I'm after, just open the Asset Store window. And try to shrink it. It elegantly doesn't allow you to do so. How?
     
  2. devast3d

    devast3d

    Joined:
    May 30, 2010
    Posts:
    76
    Resurrecting old thread, because I was looking for same functionality, but have not found. Yet later I could find it myself. Maybe someone will find it useful :)
    Code (csharp):
    1.  
    2. EditorWindow window = new EditorWindow();
    3. window.maxSize = new Vector2(215f, 110f);
    4. window.minSize = window.maxSize;
    5.  
     
  3. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,507
    Thanks..