Search Issue Tracker

Won't Fix

Votes

6

Found in

5.3.5p4

Issue ID

806690

Regression

No

[ContextMenu] Screen.width and Screen.height return inspector window dimensions

IMGUI

-

Reproduction steps:
1. Open the attached project
2. Open the available scene
3. Enable 'LogInUpdate' in the 'Test' gameobject
4. Play scene
Note: Game screen dimensions are logged in the console
5. Click 'Log in Context Menu' in the script component's Context Menu

Result: Calling Screen.width and Screen.height from the Context Menu returns Inspector window dimentions
Expected: Should return Game view screen dimentions

Comments (5)

  1. huulong

    Nov 19, 2022 20:53

    The more recent bug report is here: https://issuetracker.unity3d.com/issues/screen-dot-width-slash-screen-dot-height-in-onenable-shows-inspector-window-size-when-the-component-is-enabled-by-a-toggle-in-inspector-window

    It has been closed as By design without explanation, so I re-opened a bug report and will post my updates on the more recent bug report until a new one is opened, or it is reopened.

  2. JohannesMP

    Feb 27, 2017 12:14

    Any workarounds for this issue?

  3. ifurkend

    Dec 19, 2016 14:10

    This is ridiculous! Why on earth we would want to know about the size of the inspector window which is completely random and irrelevant to both developers and players in all cases!

  4. Hullabu

    Dec 13, 2016 13:22

    In the Editor mode Screen.width and Screen.height returns size of a currently selected inspector window instead size of the Game View.
    Unity 5.5.0p1

  5. nahoy

    Nov 23, 2016 11:07

    I'll add my two cents here :)

    First of all, this is NOT using an Editor script, if it was, we would 100% understand why Screen.width/height would return the size of the currently focused window. But here, it's a simple MonoBehaviour script.

    Obviously, we don't have the issue when building to players, because the only window is the Game window. But in editor, this should also return the GameView size, because we can't work/develop with incorrect values like that :/
    Maybe the best thing to do (as 99% of people use Screen.width/height to get the dimensions of the GameView), is to add another API to get the windows width/height... that would make more sense. So Screen.width/height would always return the GameView dimensions.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.