# pixelWidth pixelHeight behaviour

**URL:** https://discussions.unity.com/t/pixelwidth-pixelheight-behaviour/464166
**Category:** Unity Editor
**Created:** [December 26, 2011, 3:50pm UTC](https://discussions.unity.com/t/pixelwidth-pixelheight-behaviour/464166 "2011-12-26T15:50:41Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Toack](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/toack/32/984144_2.png) [@Toack](https://discussions.unity.com/u/Toack)
#### Post date: [December 26, 2011, 3:50pm UTC](https://discussions.unity.com/t/pixelwidth-pixelheight-behaviour/464166/1 "2011-12-26T15:50:41Z")

</div>

I’m doing an editor script and when I access pixelWidth and pixelHeight properties of a given Camera (i.e. Camera.mainCamera) I get the values for the editor window instead of the game view

I would like to get 1024x768 as my game view but instead I get 254x289 as the editor window, if I resize the editor window for that specific script the values change, I don’t know how to correct this or if this is the intended behavior.

Thanks in advance!

---

<div class="post-metadata">

### Author: ![anon\_30346565](https://avatars.discourse-cdn.com/v4/letter/a/53a042/32.png) [@anon\_30346565](https://discussions.unity.com/u/anon_30346565)
#### Post date: [January 28, 2012, 11:58pm UTC](https://discussions.unity.com/t/pixelwidth-pixelheight-behaviour/464166/2 "2012-01-28T23:58:43Z")

</div>

Hi, I think this is what you need:

```auto
    public static Vector2 GetScreenSize() {
        Type T = System.Type.GetType("UnityEditor.GameView,UnityEditor");
        MethodInfo GetSizeOfMainGameView = T.GetMethod("GetSizeOfMainGameView", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
        object Res = GetSizeOfMainGameView.Invoke(null, null);
        return (Vector2)Res;
    }

```

in order to get the GameView size inside of an editor script, and you can use it to get pixelWidth or pixelHeight of a specific camera

```auto
int pixelWidth = GetScreenSize().x * camera.rect.width

```
