当前位置:网站首页>Unity screen adaptation
Unity screen adaptation
2022-04-23 07:47:00 【youth who behaves like an adult】
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;
// Actual orthographic viewport = Initial orthographic viewport * Initial aspect ratio / Actual aspect ratio
GetComponent<Camera>().orthographicSize = (initOrthoSize * (initWidth / initHeight)) / (factWidth / factHeight);
}
}
The core formula : Actual orthographic viewport = Initial orthographic viewport * Initial aspect ratio / Actual aspect ratio
版权声明
本文为[youth who behaves like an adult]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230626191292.html
边栏推荐
- Judge whether the beginning and end of the string contain target parameters: startswith() and endswith() methods
- SAP PI/PO rfc2RESTful 發布rfc接口為RESTful示例(Proxy間接法)
- Reflect on the limitations of event bus and the design and implementation of communication mechanism in component development process
- 踩坑日记:Unable to process Jar entry [module-info.class]
- Nacos / sentinel gateway current limiting and grouping (code)
- SAP PI/PO Soap2Proxy 消费外部ws示例
- VR、AR、MR的区别与应用,以及对AR技术的一些实现原理
- Ogldev reading notes
- Authorization+Token+JWT
- C# SmoothProgressBar自定义进度条控件
猜你喜欢
MySQL8.0 安装/卸载 教程【Window10版】
SAP PI/PO rfc2Soap 发布rfc接口为ws示例
中间人环境mitmproxy搭建
利用Lambda表达式解决c#文件名排序问题(是100大还是11大的问题)
BTREE, B + tree and hash index
移动端布局(3D转换、动画)
canvas学习第一篇
Apache Hudi 如何加速传统的批处理模式?
Django uses MySQL database to solve error reporting
How to judge whether a point is within a polygon (including complex polygons or a large number of polygons)
随机推荐
SampleCameraFilter
设置了body的最大宽度,但是为什么body的背景颜色还铺满整个页面?
int a = 1存放在哪
Mobile game performance optimization
Nacos / sentinel gateway current limiting and grouping (code)
快排的练习
unity UGUI判断点击在UI上和3D物体上的解决方案
14. Transaction processing
Processing of common dependency module
Solutions to common problems in visualization (VII) solutions to drawing scale setting
层次输出二叉树
5. Sql99 standard: internal connection and external connection
Common DOS commands
手游的热更方案与动态更新策略
C# 多个矩形围成的多边形标注位置的问题
颜色转换公式大全及转换表格(31种)
Preliminary configuration of OpenGL super Dictionary (freeglut, glew, gltools, GLUT)
取得所有点列表中的最大值GetMaxPoint
MySQL index
Hot change scheme and dynamic update strategy of mobile game