STRANGE error with screen.height/screen.width

I have a really strange error with getting the screen size

private var bildBreite = Screen.width;
private var bildHoehe = Screen.height;
function OnGUI(){

This script give me back width = 1252 (Correct) and height = 30?? (Sometimes 20??)

Instead when I directly use Debug.Log(Screen.height); it is correct?

Whats this for a really strange problem?


you really shouldn't be setting it there (It's set before things are completely set up if you do)

put the assign in Awake or Start, and it should fix the problem