admin管理员组文章数量:1516870
void Start()
{
//16:9任意拉伸
aspect16_9 = 1.777777778f;
Camera.main.aspect = aspect16_9;
} private void OnPreRender()
{
//窗口化中拉伸窗口时等比例缩放以保持16:9
float currentAspect = System.Convert.ToSingle((double)Screen.width / Screen.height);
if (currentAspect > Camera.main.aspect)
{
Camera.main.pixelRect = new Rect(0, 0, Screen.height * 16 / 9.0f, Screen.height);
Camera.main.pixelRect = new Rect(Screen.width / 2 - Camera.main.pixelWidth / 2, Screen.height / 2 - Camera.main.pixelHeight / 2, Camera.main.pixelWidth, Camera.main.pixelHeight);
}
else if (currentAspect < Camera.main.aspect)
{
Camera.main.pixelRect = new Rect(0, 0, Screen.width, Screen.width / 16.0f * 9);
Camera.main.pixelRect = new Rect(Screen.width / 2 - Camera.main.pixelWidth / 2, Screen.height / 2 - Camera.main.pixelHeight / 2, Camera.main.pixelWidth, Camera.main.pixelHeight);
}
}版权声明:本文标题:搞定PC端Unity游戏分辨率:打造黄金比例16:9视效 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.betaflare.com/biancheng/1771049110a3261473.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论