Unity
- 3 ответа
- 0 вопросов
1
Вклад в тег
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraController : MonoBehaviour
{
public int Mobile = 640;
public int Tablet = 852;
void Start()
{
if (Camera.main.pixelHeight > Camera.main.pixelWidth){
//PORTRAIT
float ratio = (float) Camera.main.pixelHeight/Camera.main.pixelWidth;
if (ratio >= 1.5f)
{
Camera.main.orthographicSize = (float) (Mobile*ratio)/200f;
}
else
{
Camera.main.orthographicSize = (float) (Tablet*ratio)/200f;
}
}
else
{
//LANDSCAPE
float ratio = (float) Camera.main.pixelWidth/Camera.main.pixelHeight;
if (ratio >= 1.5f)
{
Camera.main.orthographicSize = (float) Mobile/200f;
}
else
{
Camera.main.orthographicSize = (float) Tablet/200f;
}
}
}
}