- Home /
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(){
Debug.Log(bildBreite);
Debug.Log(bildHoehe);
}
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?
Thanks
Answer by Mike 3 · Jun 16, 2010 at 04:05 PM
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
Thanks, when putting it into awake, it is working fine.
Dont know why width worked but ok :)
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Setting Scroll View Width GUILayout 1 Answer
Screen Sizes - HUD - Button Layout - Camera. 0 Answers
Auto scaling GUI 3 Answers
Change GUI size 1 Answer