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

Resolved Editor window: Set minWidth and Screen.width at min are different. Why?

Discussion in 'Scripting' started by Falcoshin, Jun 24, 2021.

  1. Falcoshin

    Falcoshin

    Joined:
    May 31, 2017
    Posts:
    168
    What it says on the tin. I don't understand what's causing it. I set the window's minSize to 225, 325 and have a label that tells me what the current Screen.width is at all times and, when I reduce the window to min, the label always reads 281 rather than 225. Why is this?
     
  2. Bunny83

    Bunny83

    Joined:
    Oct 18, 2010
    Posts:
    3,528
    Why do you think that Screen.width has anything to do with the size of one of your EditorWindows? You should read the position property of your editor window if you want to know the current size and location of the window.
     
  3. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    9,907
    Screen.width in some editor context refers to the space your editor script handles. At least it used to in IMGUI times. I don't know how chaotic it is nowadays when more things go to Toolkit.

    Anyway, it is easy to confuse ourselves with this. Never liked it.
     
  4. Falcoshin

    Falcoshin

    Joined:
    May 31, 2017
    Posts:
    168
    This video told me so
     
  5. Falcoshin

    Falcoshin

    Joined:
    May 31, 2017
    Posts:
    168
    Incidentally, someone informed me about position a while before you replied. It's exactly what I was looking for.
     
  6. Bunny83

    Bunny83

    Joined:
    Oct 18, 2010
    Posts:
    3,528
    Did you actually read any of the comments below that video? "Nitras Interactive" pointed out that error already 4 years ago and the creator of the video acknowledged the mistake. "Beaver Joe" also mentioned that mistake and suggested using position instead.

    So just be careful in the future when you follow the advice of someone, even my own. People make mistakes or information may get outdated (the video upload is from 2016).