UGUI的UI自动填充整个屏幕的脚本
2017-05-02 09:26
225 查看
using UnityEngine; using System.Collections; using UnityEngine.UI; public class UIself : MonoBehaviour { [SerializeField] Vector2 sizeDelta; float W; float H; float sW; float sH; RectTransform rt; // Use this for initialization void Start() { rt = this.GetComponent<RectTransform>(); sW = Screen.width; sH = Screen.height; SetPos(sizeDelta); } void SetPos(Vector2 v2) { rt.sizeDelta = v2 * 9 * Screen.width / (16 * Screen.height); } // Update is called once per frame void Update() { if (sW != Screen.width || sH != Screen.height) { SetPos(sizeDelta); sW = Screen.width; sH = Screen.height; } } }注意:rt.sizeDelta = v2 * 9 * Screen.width / (16 * Screen.height); 这一句是屏幕宽高比为9:16时做的操作,如果宽高比不是9:16,就得自己改
相关文章推荐
- 自定义ViewGroup流式布局,自动填充满整个屏幕
- 自定义ViewGroup 五彩缤纷的流式布局,并且自动填充满整个屏幕
- 背景自动填充整个屏幕,
- VS2010测试功能之编码的UI测试之自动生成脚本的结构
- unity3d UI自动适合屏幕分辨率
- java图片缩放实现图片填充整个屏幕
- UGUI自动判断UI层次
- webview自动填充屏幕
- 根据屏幕分辨率自动实现页面全屏的脚本
- Shell脚本(自动填充函数模板)
- Unity之UGUI脚本自动生成
- 图片按屏幕大小缩放,不能填充整个屏幕
- 如何让Canvas画笔填充满整个浏览器屏幕
- 如何通过CSS实现背景图片自动平铺或拉伸至整个屏幕(自适应大小)
- 关于jquery ui auto complete自动填充
- [UGUI] 用脚本给UI绑定事件2
- 如何让MFC中listctrl自动填充整个对话框窗口
- dialog填充整个屏幕
- body里放一个背景图片,浏览的时候填充整个屏幕
- unity3d ugui中如何获取ui控件位置?或者说如何将ugui中ui控件(组件)的坐标转化为屏幕坐标或canvas坐标(大坑)?