public class ScreenResolutionService
{
public void setScreenConfiguration(ref float height, ref float width)
{
float resolutionFactor = (float)Screen.width / (float)Screen.height;
height = 2 * Camera.main.orthographicSize;
width = resolutionFactor * height;
}
}
public class GameLogic : MonoBehaviour
{
private float height;
private float width;
private ScreenResolutionService screenResolutionService = new ScreenResolutionService();
void Start()
{
screenResolutionService.setScreenConfiguration(ref height, ref width);
anyGameObject.transform.localScale += new Vector2(width/2 , height/2);
}
void Update()
{
}
}