- Home /
Android different resolutions in 3D (not GUI)
Hi,
I've been looking all over the internet for some type of guide on how to make your Unity game work best on all the different Android resolutions.
I have come across alot of questions and answeres regarding how to make GUI work, but nothing on how to actually set up your 3d space to work well. Everyone just seem to assume it works... but does it? How?
Can anyone explain exactly how it works? If I have a game that is purely 3D (no GUI), is there a way to make it work on all Android resolutions available without having to make different versions of the game for each different resolution / aspect ratio?
I am developing a puzzle game in 3D so I need to keep my objects on specific locations in 3D world, and make them appear exactly, or at least almost exactly, at the same place on the screen in different resolutions.
Any suggestions which is the easiest way to accomplish this? Or if you have seen this asked somewhere else, or know some type of guide, etc. I just cant find any real good info anywhere.
Thanks!
Is your game using an orthographic camera?
camera.main.orthograhicSize
Orthographic $$anonymous$$ath: http://forum.unity3d.com/threads/113641-Orthographic-screen-size
Orthographic $$anonymous$$ath Answer: http://answers.unity3d.com/questions/174002/what-is-the-relationship-between-camera-size-units.html
If you are using an orthographic camera, here's a previous answer for you.
http://answers.unity3d.com/questions/174002/what-is-the-relationship-between-camera-size-units.html
Answer by Eric5h5 · Jan 27, 2012 at 01:00 AM
3D is inherently resolution-independent. If the camera is at position 0,0,-10 pointing forward and an object is at position 5,0,0, then the object will always appear in the same relative position no matter what the resolution is. The only thing you have to be concerned with is aspect ratio; the general approach is just to make sure everything critical can be seen in 4:3.
Eric: Yeah thats basically what I was thinking too... that its the aspect ratio that is the main problem.
On a mobile phone screen in puzzle game I really cant afford to "waste" everything outside the 4:3 aspect. Especially not since most screens have an aspect ratio more similar to 3:2 or 16:9 and a couple of odds ones in between.
Thats why I wonder how to approach that problem. If its somehow possible to calculate or scale the position and size of object to make it work on different aspect ratios (using all available screen size), or if I manually need to create different versions of the game for all the different aspect ratios...?
I make a game board that I test in each aspect ratio. That's how I made my last five board games. I put 3D text meshes for scores and information. For elements in the game, I use ray casting and check mouse buttons for clicks. It avoids all the disconnect between the GUI and game objects.
However, if I were really concerned about it, I would make the game board and size the camera based on the screen size. I just happen to have made all my game boards functional in 4:3, like Eric mentioned.
@pigghaj: you'd use whatever the narrowest aspect ratio is. If nothing your game runs on is narrower than 3:2, then make 3:2 the standard.
Hanse: This is for Android phones though, so I cant just do it 4:3 since there are so many phones with very different resolutions and aspects ratios. I could resize the camera depending on aspect ratio but it still would mean I am probably gonna have issues with unused space in some aspect ratios i think?
Eric: I am thinking there has to be a better way. Have you ever seen an Android game that doesnt fill out the whole screen?:) But perhaps the only way is manually arranging things for different aspect ratios...
Eric is correct about the narrowest aspect ratio usage. All the boards I've used have been exactly square, so I haven't had to make a rectangular area fit in Unity. All my apps work on Android devices and I haven't had aspect issues with them (phones and tablets). However, I did lock them to landscape mode.
Answer by Pigghaj · Jan 27, 2012 at 03:26 AM
Hanseshadow:
I have also decided not to use GUI and instead keep everything as 3D object. But I am not sure how to present text and numbers. In my 2D version I use sprites that contains the text I need to show. You said you used 3d meshes for text? And this works fine? I am thinking it could have a big impact on performance if you have alot of text and stuff in 3d?
3D Text $$anonymous$$eshes are not a huge impact. Each character is two polygons. If you had 1000 words of 8 average characters, that's only 16000 polygons. I highly doubt you would ever have that many words on a page, much less in a scene.
Besides, as a senior technical designer who has done many AAA games in the past 20 years, people do not like to read. They're lazy. :)
Answer by BroVodo · Sep 11, 2012 at 02:42 PM
var edge : int = -1;//which screen edge 0 - 4, top, right, bottom, left
var edgeCam : Camera;
function Start()
{
ToEdge( edge );
}
function ToEdge( e : int )
{
if( e == -1 )
{
return;
}
var b : Bounds = renderer.bounds;
var t : float = 0.0;
var se : Vector3 = Vector3( 0, 0, 0 );//screen edge
var translateAmount : Vector3 = Vector3( 0, 0, 0 );
if( e == 0 )//top
{
se = edgeCam.ViewportToWorldPoint( Vector3( 0, 1, 0 ) );
t = se.y - b.center.y - b.extents.y;
translateAmount = Vector3( 0, t, 0 );
}
if( e == 1 )//right
{
se = edgeCam.ViewportToWorldPoint( Vector3( 1, 0, 0 ) );
t = se.x - b.center.x - b.extents.x;
translateAmount = Vector3( t, 0, 0 );
}
if( e == 2 )//bottom
{
se = edgeCam.ViewportToWorldPoint( Vector3( 0, 0, 0 ) );
t = se.y - b.center.y + b.extents.y;
translateAmount = Vector3( 0, t, 0 );
}
if( e == 3 )//left
{
se = edgeCam.ViewportToWorldPoint( Vector3( 0, 0, 0 ) );
t = se.x - b.center.x + b.extents.x;
translateAmount = Vector3( t, 0, 0 );
}
transform.Translate( translateAmount );
}
This script will move 3d elements to the edge of an isometric camera. It's helpful for making maximum use of screen space at different resolutions.
Your answer
Follow this Question
Related Questions
Android Screen Resolution (Joysticks) help. 2 Answers
Making Unity player background as transparent in android app 0 Answers
Android live wallpaper 1 Answer
A node in a childnode? 1 Answer
3rd Person Control for Android? 0 Answers