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. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

[solved]How to get the size of EditorWindow?

Discussion in 'Immediate Mode GUI (IMGUI)' 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?
     
    ChaosEaterY likes this.
  2. matthewminer

    matthewminer

    Joined:
    Aug 29, 2005
    Posts:
    330
    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. }
     
  3. h.istvan

    h.istvan

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

    hankchen

    Joined:
    Sep 18, 2014
    Posts:
    2
    thanks
     
    ChaosEaterY likes this.
  5. HuJinkai

    HuJinkai

    Joined:
    Aug 12, 2018
    Posts:
    3
    thx
     
    ChaosEaterY likes this.
  6. OYup

    OYup

    Joined:
    Nov 3, 2021
    Posts:
    1
    ty
     
    ChaosEaterY likes this.
  7. ChaosEaterY

    ChaosEaterY

    Joined:
    Jun 3, 2018
    Posts:
    1
    ty very much
     
  8. HairlessGorilla

    HairlessGorilla

    Joined:
    Mar 4, 2021
    Posts:
    37
  9. lambmeow

    lambmeow

    Joined:
    May 12, 2014
    Posts:
    1