不同分辨率适配
下列 750 1334 是我屏幕的分辨率,可以将数值更换成自己的。直接挂在主摄像机上。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
//近大远小的摄像机
public class ShiPei : MonoBehaviour
{
void Awake()
{
float targetHight = 1334f;
if (750 * Screen.height > 1334f * Screen.width) {
targetHight = 750 * Screen.height / Screen.width;
}
Camera.main.fieldOfView *= (targetHight / 1334f);
}
}