当前位置:网站首页>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
边栏推荐
- Mobile game performance optimization
- Implementation of MySQL persistence
- 【TED系列】如何与内心深处的批评家相处?
- 移动Web(字体图标、平面转换、颜色渐变)
- 中间人环境mitmproxy搭建
- 基于NLP的软件安全研究(一)
- 每日一题 | 曾被反转链表支配的恐惧
- js案例之求最大值,反转数组,冒泡排序
- The difference and application of VR, AR and MR, as well as some implementation principles of AR technology
- int a = 1存放在哪
猜你喜欢
SAP CR传输请求顺序、依赖检查
SAP PI / Po rfc2restful Publishing RFC interface as restful examples (proxy indirect)
BTREE, B + tree and hash index
MySQL index
Custom time format (yyyy-mm-dd HH: mm: SS week x)
canvas学习第一篇
反思 | Android 音视频缓存机制的系统性设计
FSM有限状态机
redis连接出错 ERR AUTH <password> called without any password configured for the default user.
Configure NPM
随机推荐
js之DOM学习三种创建元素的方式
State synchronization and frame synchronization
NodeJS(六) 子进程操作
Judge whether the beginning and end of the string contain target parameters: startswith() and endswith() methods
SAP pi / PO rfc2soap publishes RFC interface as WS example
王者荣耀-unity学习之旅
C# SmoothProgressBar自定义进度条控件
系统与软件安全研究(四)
[self motivation series] what really hinders you?
Configure NPM
颜色转换公式大全及转换表格(31种)
快速排序
移动Web(字体图标、平面转换、颜色渐变)
c#读取INI文件和向ini文件写入数据
js中对象的三种创建方式
'NPM' is not an internal or external command, nor is it a runnable program or batch file
防抖和节流
2. Restricted query
The difference and application of VR, AR and MR, as well as some implementation principles of AR technology
Ogldev reading notes