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
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
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- UI Overlay Image gets darker on each Camera when multiple Cameras are used
- Assertion failed on expression: 'scriptedImporterClass == SCRIPTING_NULL error when opening the standalone profiler window
- Disabled assets in Import Unity Package window aren't tracked but count as being selected by user
- [Windows] Crash on GetManagerFromContext when video is playing and creating High Definition 3D Projects after FMOD failed to switch back to normal output Error appeared
- GC Alloc produced when adding items to MultiColumnListView with Auto Assign Binding
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.
JohannesMP
Feb 27, 2017 12:14
Any workarounds for this issue?
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!
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
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.