I got same problem for atleast 2 week until i figured myself how to handle object in different resolution which preventing object falling apart or place object based with the screen resolution .
If you want to keep the object right in the position following camera , don't forget to put the object inside camera object .
this is my script to control the resolution :
calculateresolution.cs
using UnityEngine;
using System.Collections;
public class calculateresolution : MonoBehaviour {
// change this to resolution size when you create the game
float desiredscreenheights = 768;
float desiredscreenwidths = 1366;
void CalculateResolution(string theobjectm) {
GameObject objecttocalculate = GameObject.Find(theobjectm);
float desiredscreenheight = desiredscreenheights;
float desiredscreenwidth = desiredscreenwidths;
float desiredaspectratiowidth = desiredscreenwidth / desiredscreenheight;
float desiredaspectratioheight = desiredscreenheight / desiredscreenwidth ;
float screenheight = Screen.height;
float screenwidth = Screen.width;
float aspectratioheight = screenheight / screenwidth;
float aspectratiowidth = screenwidth / screenheight;
Debug.Log (screenheight + " " + screenwidth + " " + aspectratioheight + " " + aspectratiowidth);
float objectsizex = objecttocalculate.transform.localScale.x;
float objectsizey = objecttocalculate.transform.localScale.y;
float objectsizez = objecttocalculate.transform.localScale.z;
float objectcoordx = objecttocalculate.transform.localPosition.x;
float objectcoordy = objecttocalculate.transform.localPosition.y;
float objectcoordz = objecttocalculate.transform.localPosition.z;
Debug.Log (objectsizex + " " + objectsizey + " " + objectsizez + " " + objectcoordx + " " + objectcoordy + " " + objectcoordz);
float newobjectsizex = aspectratiowidth / desiredaspectratiowidth * objectsizex;
float newobjectsizey = objectsizey;
float newobjectsizez = objectsizez;
float newobjectcoordx = aspectratiowidth / desiredaspectratiowidth * objectcoordx;
float newobjectcoordy = aspectratiowidth / desiredaspectratiowidth * objectcoordy;
float newobjectcoordz = objectcoordz;
Debug.Log (newobjectsizex + " " + newobjectsizey + " " + newobjectsizez);
Debug.Log (newobjectcoordx + " " + newobjectcoordy + " " + newobjectcoordz);
objecttocalculate.transform.localScale = new Vector3 (newobjectsizex, newobjectsizey, newobjectsizez);
objecttocalculate.transform.localPosition = new Vector3 (newobjectcoordx, newobjectcoordy, newobjectcoordz);
Debug.Log ("Calculate Finish For Now");
}
void Start () {
}
// Update is called once per frame
void Update () {
// your gameobject name
CalculateResolution ("yourobjectname ");
}
}
To calculate the object , just call CalculateResolution("yourgameobjectname") , change yourgameobjectname with the object name .
Change "float desiredscreenwidths" and "float desiredscreenheights" value to resolution size you use to build the game .
But unfortunally this script does not support screen rotation because i did not know how to :I sorry , or maybe you tell me how ;) .