- Home /
Resolution problem!!!
Hi all,
Lets say I have a 3D Camera showing four cubes as walls, these are the boundaries of my game.
And now I've to show these boundaries on the same position as they are on the editor, for every phone resolution (Android and iOS both).
Please suggest me what should I do to achieve this.
Answer by guykogus · Nov 22, 2013 at 12:08 PM
I used this handy little script:
public class CameraAnchor : MonoBehaviour
{
public Vector2 position;
void Start ()
{
Camera cam = Camera.main;
// Answer thanks to http://answers.unity3d.com/questions/481884/keep-gameobject-on-a-corner-of-the-screen.html
transform.position = cam.ViewportToWorldPoint(new Vector3(position.x, position.y, -cam.transform.position.z));
}
}
Which lets you set an anchor position on the screen. Setting position
to (0,0) places it at the bottom-left, while (1,1) is top-right. Hope that helps :)
Answer by Ben-Stoneman · Nov 20, 2013 at 10:48 AM
This is useful: http://forum.unity3d.com/threads/78154-Supporting-Multiple-iOS-Resolutions-(iPad-iPhone4-3GS)
It would be done by a script that checks the screen width and height of the device it is running on in order to adjust accordingly.
Hi Ben,
First, sorry for replying late, and second, if I go with Screen.width and Screen.height, it could create a real mess for me as there are too many Android resolutions. I've to set it for many resolutions.
Now here is the thing, I have two cameras, 2D and 3D in my scene and I am using NGUI ( 2D Camera ) which helped me in seeing all the 2D UI and which itself helped me manage all the 2D stuff of the game accordingly ( seen same on all devices ). On the other hand 3D Camera shows the 3D UI, so now what I really need is, some stuff or some technique which could manage my 3D stuff in the same manner.