Search Unity

  1. Unity 2018.3 is now released.
    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've updated our Terms of Service. Please read our blog post from Unity CTO and Co-Founder Joachim Ante here
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

[solved]How to get the size of EditorWindow?

Discussion in 'Extensions & OnGUI' started by h.istvan, Jan 18, 2010.

  1. h.istvan

    h.istvan

    Joined:
    Aug 4, 2009
    Posts:
    77
    Hello!
    Recently I started to write a custom Editor script in C#,and I want to place buttons, that stick to the bottom-right side of the window even on resizing.
    My problem is that I don't know how to get the width and the height of the window.
    Any good idea?
     
  2. matthewminer

    matthewminer

    Joined:
    Aug 29, 2005
    Posts:
    320
    Use EditorWindow.position to get your window's Rect, which you can get the width and height of.

    Code (csharp):
    1. void OnGUI () {
    2.     Debug.Log("Window width: " + position.width);
    3. }
     
    HenryJV, Pecek, LightingBox2 and 2 others like this.
  3. h.istvan

    h.istvan

    Joined:
    Aug 4, 2009
    Posts:
    77
    Thank you very much, it is exactly what I was looking for! :wink:
     
    TaleOf4Gamers likes this.
  4. hankchen

    hankchen

    Joined:
    Sep 18, 2014
    Posts:
    2
    thanks