sing UnityEngine;
public class CamearAdaptation : MonoBehaviour
{
public float initOrthoSize;
public float initWidth;
public float initHeight;
float factWidth;
float factHeight;
void Start ()
{
factWidth = Screen.width;
factHeight = Screen.height;
//实际正交视口 = 初始正交视口 * 初始宽高比 / 实际宽高比
GetComponent<Camera>().orthographicSize = (initOrthoSize * (initWidth / initHeight)) / (factWidth / factHeight);
}
}
核心公式:实际正交视口 = 初始正交视口 * 初始宽高比 / 实际宽高比