直接上代码:
float scaleFactor = 1.0f;
if (横屏)
{
scaleFactor = (1920.0f / 1080.0f) / (Screen.width/ Screen.height);
}
else
{
scaleFactor = (1080.0f / 1920.0f) / (Screen.width / Screen.height);
}
this.transform.localScale = Vector3.one * scaleFactor;
scaleFactor = 原始宽高比/当前屏幕宽高比