x


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

more ▼

asked Jun 16 '10 at 04:03 PM

Tobias gravatar image

Tobias
378 50 54 66

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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

more ▼

answered Jun 16 '10 at 04:05 PM

Mike 3 gravatar image

Mike 3
30.5k 10 65 253

Thanks, when putting it into awake, it is working fine.

Dont know why width worked but ok :)

Jun 16 '10 at 04:33 PM Tobias
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x5089
x3694
x486
x286

asked: Jun 16 '10 at 04:03 PM

Seen: 2097 times

Last Updated: Jun 16 '10 at 04:03 PM