美文网首页
Unity手机宽度适配

Unity手机宽度适配

作者: Albert_d37d | 来源:发表于2020-06-24 15:19 被阅读0次

    private void MatchScreen()

        {

            float screenHeight = Screen.height;

            float orthographicSize = this.GetComponent<Camera>().orthographicSize;

            float aspectRatio = Screen.width * 1.0f / Screen.height;

            float cameraWidth = orthographicSize * 2 * aspectRatio;

            if (cameraWidth < devWidth)

            {

                orthographicSize = devWidth / (2 * aspectRatio);

                this.GetComponent<Camera>().orthographicSize = orthographicSize;

            }

        }

    相关文章

      网友评论

          本文标题:Unity手机宽度适配

          本文链接:https://www.haomeiwen.com/subject/ewbrfktx.html