- Home /
Cannot see full view of Screen in Unity preview
Hi all,
I have been making a 2D sprite-based game in Unity for a couple of months now, and this issue is really starting to get in the way.
First off, here are some stats that may be relevant:
Game's target resolution: 1280 x 768
Unity Player settings: 1280 (width), 768 (height)
Unity Game preview pane setting: Standalone (1280 x 768). I am aware of Maximize on Play and use it almost all the time. The problem persists.
Camera Settings: Projection (Orthographic), Camera size = 384
The issue is this: I cannot seem to get a full view of the screen in the unity Game view preview pane. This is most apparent when I script GUI elements through OnGUI(). In fact, all the game world assets show up fine, its only the GUI that doesn't show up right. It seems like Unity is only showing the top left part of the screen but it tries to squeeze in all the GUI into the preview screen despite it not fitting. Especially when I code in values like Screen.height and Screen.width.
Here is one example: When I want something to be on the bottom left corner of the screen, I code something like this.
if (GUI.Button(new Rect(0, Screen.height - 60, 682, 73), "Level Select"))
{
StartCoroutine ( Dofadeout ("LevelSelect") );
}
Now, I also have a texture on the left side of the screen that starts at (0, 134) and spans 574 units downward. In the Unity preview "world" the texture and button are seen as overlapping. But when I actually build the project and look at the same screen, they are as they are supposed to be. They are not overlapping.
Everything is alright in the "real world". But the unity preview pane squeezes OnGUI elements together making it impossible for me to visually place them unless I build the game every time I want to check the "real" position of the GUI. Any help would be appreciated.
Edit: I have attached some pics for reference. First one is in Unity, 2nd one is build.
Edit2: Someone suggested something that I should have done at the beginning of this post. I scripted in some labels to reveal the actual current Screensize thorough Screen.width and Screen.height and added a third pic to show this. It was revealed that I had been working in 1063 x 638. So basically the Standalone (1280 x 768) is a straight up lie?
Answer by kristercollin · Sep 20, 2012 at 07:35 AM
I know what you're referring to, it's frustrating but I've learnt that to test it properly I either want to have the game view set to Maximize on Play or give the preview pane enough space that it will display at the correct resolution (annoying though that may be).
I'm sorry I can't be of any further assistance.
Answer by Shrandis · Sep 20, 2012 at 01:38 PM
When the game view is too small to fully display the selected resolution, it resizes itself while maintaining the aspect ratio. You need to resize the game view to the resolution you want to display. You can know whether you enlarged it enough or not by checking the "grey edges". If all 4 sides of the game window has grey edges, selected resolution will be correctly displayed. I took 2 screenshots to better explain what I meant.
Hi Shrandis,
Thanks for taking the time to do screenshots. I have attached a few screenshots myself. In comparison, It seems like $$anonymous$$e does not have gray on the top and bottom. How would I achieve that? I have already set the preview resolution to (Standalone) 1280 x 768 which is the target resolution. Anything besides this just makes it smaller.
You have grey areas on the top in your first screenshot. You need to make sure both the top and bottom have at least some grey (so you know the window's resolution is correct) Notice how the resolution is the same 960x600 in both of my screenshots, but in the first one, the window is resized to be very small, so the actual game window shrinked (ins$$anonymous$$d of being cropped) while still having the same aspect ratio.
Honestly it is such a strange solution to a strange problem that I'm having a hard time explaining it properly.
Since I am working on a laptop, could it be that my laptop resolution is not big enough to support a unity preview pane with 1280 x 768 resolution? $$anonymous$$y native screen resolution is 1366 x 768 though so it shouldn't be a problem?
Ugh, this problem is really stressing me out now :(. Thanks for the input though.
Your answer
Follow this Question
Related Questions
How to scale all sprites, gui buttons, texts, images, 3d objects proportional to the screen height 1 Answer
Adjust overlay position for different resolutions 0 Answers
[Button with animator] vs. [Sprite with mousedetection] 0 Answers
Why is my sprite not the original resolution? 2 Answers
Sprite Editor : how to use Sprites created by SpriteEditor via script ( not via inspector ) 0 Answers