当前位置:网站首页>unity 屏幕自适应
unity 屏幕自适应
2022-04-23 06:27:00 【老少年】
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);
}
}
核心公式:实际正交视口 = 初始正交视口 * 初始宽高比 / 实际宽高比
版权声明
本文为[老少年]所创,转载请带上原文链接,感谢
https://blog.csdn.net/laoshaonian/article/details/99719320
边栏推荐
- js之预解析
- The difference and application of VR, AR and MR, as well as some implementation principles of AR technology
- 刨根问底---cocos2d源码的理解与分析
- 4. Multi table query
- SVG中年月日相关的表达式
- SAP PI / Po rfc2restful Publishing RFC interface as restful examples (proxy indirect)
- C# SmoothProgressBar自定义进度条控件
- typescript字典的使用
- Date object (JS built-in object)
- 对js中argumens的简单理解
猜你喜欢

King glory - unity learning journey

Install and configure Taobao image NPM (cnpm)

SAP SALV14 后台输出SALV数据可直接保存文件,发送Email(带排序、超链接、筛选格式)

h5本地存储数据sessionStorage、localStorage

canvas学习第一篇

MySQL8.0 安装/卸载 教程【Window10版】

设置了body的最大宽度,但是为什么body的背景颜色还铺满整个页面?

SAP PI/PO Soap2Proxy 消费外部ws示例

js之DOM事件

Apache Hudi 如何加速传统的批处理模式?
随机推荐
3. Sort statement
C# SmoothProgressBar自定义进度条控件
NodeJS(四) 字符读取
SAP PI/PO Soap2Proxy 消费外部ws示例
将指定路径下的所有SVG文件导出成PNG等格式的图片(缩略图或原图大小)
SAP TRANSLATE使用数据对象掩码示例
Mysql 索引
11. Table and library management
Date对象(js内置对象)
King glory - unity learning journey
h5本地存储数据sessionStorage、localStorage
根据某一指定的表名、列名及列值来向前或向后N条查相关列值的SQL自定义标量值函数
移动端布局(3D转换、动画)
【TED系列】如何与内心深处的批评家相处?
Super classic & Programming Guide (red and blue book) - Reading Notes
9. Common functions
驼峰命名对像
Nacos / sentinel gateway current limiting and grouping (code)
6. Aggregation function and grouping statistics
[self motivation series] what really hinders you?