- Home /
Android Galaxy Nexus Resolution Question, not really 1280 x 720?
So I am in the early stages of developing a new game for Android. I recently decided that I should learn how to do all the formatting for various screen sizes now, even though it's really not what I want to be focusing on. My concern is that the longer I wait it will be even harder to fix, I might as well do it right from the start?
My game will be required to be played in horizontal-left orientation, similar to most the popular apps I have tested. I am brand new to Android formatting but I am attempting to use something like this for my GUI functions:
void OnGUI()
{
float rx = Screen.width/ native_width;
float ry = Screen.height / native_height;
GUI.matrix = Matrix4x4.TRS (new Vector3(0, 0, 0), Quaternion.identity, new Vector3 (rx, ry, 1));
}
This code is intended to format the basic GUI elements automatically based on the devices resolution.
For more clarity to what exactly I am doing this is my native resolution variables:
float native_width = 1280;
float native_height = 720;
This is an example of how I am trying to format positions for things like buttons. Is there a better way to do this? I seem to have things working fine on my device now but I am not sure if this is a good method for all resolutions?
screenPosition.x= screenPosition.x *( Screen.width/ native_width);
screenPosition.y= screenPosition.y * (Screen.height/native_height);
Is it OK to use pixels at all for minor elements such as an enemy Healthbar floating over their head? Or should I eliminate pixels entirely from all display elements?
I noticed that when I don't manually declare:
Screen.SetResolution(1280, 720, false);
The health bar is slightly off center when using pixels for it's position, so I have to do it manually right now. This is unexpected because my phone is listed to have a resolution of 1280 x 720? Is this normal to have to set the resolution for your native resolution?
The problem seems to be that the sidebar on my phone is taking up some of those pixels. I tried to measure it with a ruler and I got 1181.54 x 720 for my resolution. After looking around on some other websites I found other Galaxy Nexus users reporting their usable screen size width was 1184?
I was able to confirm that this was the problem by not using :
Screen.SetResolution(1280, 720, false);
Instead I set my native_width to:
float native_width = 1184;
So I am confused about what is the best way to handle this kind of thing? If I am not even fully sure what to do on my own phone, I am kind of scared I will do it wrong for the other sizes.
So my question is:
Is it normal to have to manually set your resolution to what your native resolution should already be? Would this cause problems for the pixel ratios (and image quality) if I am using 1280x720 in a screen space that seems to technically be 1184 x 720? Should I just be able to manually set 1280x720 and then use my GUIScript matrix and some other adjustments and it would work fine on all Android devices?
I still really need help with this topic guys. If anyone can help me I would be very thankful!
I have been trying to search the forums a ton for these solutions but I am having trouble finding anything.
There's got to be someone out there who can help?
I have looked all over the place on these forums and others and I cannot find an answer of whether manually setting the resolution to (1280, 720) will negatively affect image quality due to the sidebar causing the screen to be a different resolution.
It seems like all Android devices have the mandatory sidebars, so maybe I am just freaking out over nothing? Do the devices have no problem formatting even when the aspect ratios and pixel counts are not exactly correct?
Update: I have shortened my question quite a bit since it's original post. The majority of my problems were caused because Unity does not allow you to accurately test your game in their programs "Game" view in my desired resolutions.
This will make it much more difficult than it should be to ensure that my game will be running with exact precision in all the Android device resolutions...
Seriously they don't have 1280x 720 in their game view? This problem is forcing me to only be able to test my game effectively when I build the game on my phone... very annoying.
Does the GUI.matrix function not work correctly in their "Game" view? When I test the resolution 800 x 480 in their "Game" view everything looks completely wrong. But then when I built the game on my friends phone which is also 800 x 480 everything looked fine.
Is it actually impossible to test Android games without building them and using the phone? Even Unity Remote seems to not work correctly...
I am somewhat relieved that my codes seem to be working when the build gets to a real phone. But I am EXTRE$$anonymous$$ELY disappointed about how hard it is to properly test your game within UNITY.
Update: Hmm interesting not even one response from the community on a topic that is literally required for every Android game?
Answer by Thavron · Sep 11, 2013 at 04:02 PM
I haven't used a matrix to scale my GUI (I use anchors and SD/HD atlases) so I can't help you on this part of your question, but I think I can on the testing part.
Does the GUI.matrix function not work correctly in their "Game" view? When I test the resolution 800 x 480 in their "Game" view everything looks completely wrong. But then when I built the game on my friends phone which is also 800 x 480 everything looked fine.
If you set the GameView to e.g. 800x480 its resolution isn't automatically set to that value. The GameView window's size limits the resolution. So if the GameView window is e.g. 500x400 you can't get a higher resolution than that. You have to resize the GameView and check its resolution via its Stats.
But I am EXTREMELY disappointed about how hard it is to properly test your game within UNITY.
Yes, it's a pain to switch resolutions and resize the GameView manually or to build it just to check ... BUT I've created xARM an editor extension to make our lives a lot easier. With xARM you can preview your game at any resolution you like. The window sizes do not matter and you can even see multiple resolutions at the same time. Check it out here.
I'll accept your answer just going to assume your asset solves this problem :)
I eventually found that if I just moved the game window to my 2nd monitor I could set the Standalone resolution to (1280x720) and test the game in Unity as expected.
However it seems that this only works on my PC builds my Android builds still do not have the option to go to 1280x720 it seems, unless I'm missing something here?
So I would say that Unity could definitely do a bit of improvement here. If I didn't have a dual monitor set up for Unity the game would be impossible to test accurately while also viewing the scene at the same time.
As far as the available screen space not really being 1280x720 on the phone, it seems there is nothing you can really do about it. The game will have to be able to scale to any Android or iOS resolution anyways so you kind of just have to pick a native_resolution for the project and run with it.