- Home /
Screen.height and Screen.width Issues
I have several type of windows that use Screen.width and Screen.height. Some reason the Width of the Screen keeps going off the screen by a couple hundred pixels. I was wondering if this would be a program fault or engine fault.
ChatWindowSize = new Rect(0,Screen.height/2,Screen.width/3,Screen.height);
but Screen.height just goes beyond my window space and have to subtract about 300 to get it back on to screen. Same goes for Screen.width. I have tryed building and running it at a higher resolution. Still the window goes off the screen.
Answer by robertbu · May 13, 2013 at 08:12 PM
Take a close look at the parameter of a Rect(). They are (x,y,width,height). So you are placing your window half way down the screen with a full screen of height, so the bottom 1/2 will be cutoff.
So if I wanted to create a window that can be resized from a different resolutions. How could I fix this problem or would I have to just subtract or divide the window size by screen size
I'm not sure what you want to do. Given your code above, just divide the height by 2:
ChatWindowSize = new Rect(0,Screen.height/2,Screen.width/3,Screen.height/2);
I was trying to make it so the window would stay on screen and not off it at all times which I Figured out how to do. So if your window starting position isn't at 0 for example the Screen.height/2, ins$$anonymous$$d of where in the 2nd height position you subtract the difference so its Screen.height - Screen.height/2 which should bring the window back to the size of your screen. Hope this is making sense
Your answer
Follow this Question
Related Questions
Screen.width/Screen.height not working with multiple resolutions 0 Answers
how can i divide screen to x & y axes for different resolutions 1 Answer
Do screen.width and screen.height get updated depending on screen orientation on Android? 1 Answer
Android screen orientation: why am I getting wrong screen size values? 1 Answer
Can you tell unity to resize the Game window by a button press? 2 Answers