Unity UGUI 自适应
来源:互联网 发布:电脑查淘宝注册时间 编辑:程序博客网 时间:2024/05/22 04:38
using System.Collections;using System.Collections.Generic;using UnityEngine;using UnityEngine.UI;public class UGUIAdaptive : MonoBehaviour { // Use this for initialization void Start () { float standard_width = 960f; //初始宽度 float standard_height = 420f; //初始高度 float device_width = 0f; //当前设备宽度 float device_height = 0f; //当前设备高度 float adjustor = 0f; //屏幕矫正比例 //获取设备宽高 device_width = Screen.width; device_height = Screen.height; //计算宽高比例 float standard_aspect = standard_width / standard_height; float device_aspect = device_width / device_height; //计算矫正比例 if (device_aspect < standard_aspect) { adjustor = standard_aspect / device_aspect; } CanvasScaler canvasScalerTemp = transform.GetComponent<CanvasScaler>(); canvasScalerTemp.matchWidthOrHeight = 0.5f; //if (adjustor == 0) //{ // canvasScalerTemp.matchWidthOrHeight = 1; //} //else //{ // canvasScalerTemp.matchWidthOrHeight = 0; //} }}
阅读全文
0 0
- Unity uGUI设置自适应
- unity ugui自适应
- Unity UGUI 自适应
- Unity ugui button自适应text大小
- unity ugui图片自适应文字内容大小
- unity ugui手游自适应方法
- unity给ugui添加collider时让collider自适应
- Unity UGUI
- 【Unity&UGUI】
- [UnityUI]UGUI自适应
- UGUI自适应分辨率
- UGUI自适应屏幕
- UGUI对话框自适应
- UGUI自适应笔记
- UGUI屏幕自适应
- unity 2D 正交摄像机下 uGUi 比例与自适应问题
- 【UGUI】UGUI 文字背景根据文字大小自适应
- UGUI实现unity摇杆
- 按界去百并级引思习育回每月
- SQL的四种连接(内连接,外连接)
- mybatis中$和#的区别
- 关于Picasso加载本地图片不显示的解决办法
- hibernate系列十六:分组查询,子查询,原生sql查询,命名查询
- Unity UGUI 自适应
- java--数组1
- 那些年,关于 Java 的那些事儿
- -bash: wget: command not found 解决方法
- linux基础
- HTML指定字符集
- POJ 1741 Tree 树的点分治
- iPhone X适配以及iOS 11可能出现的常见崩溃(info.plist配置)
- 只需7步让你快速绘制甘特图