admin 管理员组文章数量: 1184232
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);
}
}版权声明:本文标题:解锁Unity游戏16:9拉伸秘籍:打造超真实PC游戏体验 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/p/1771049141a3540528.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论