Unity ngui 获取实际尺寸和设计尺寸


using UnityEngine;
private float ratio = 1f;
private float panelW;
private float panelH;

UIRoot root = GameObject.FindObjectOfType<UIRoot>();
if (root != null) {
    // 实际尺寸和设计尺寸比例
    ratio = (float)root.activeHeight / Screen.height;            
}

// 设计尺寸 panelW
= transform.GetComponent<UIPanel>().width; panelH = transform.GetComponent<UIPanel>().height;
// 实际尺寸 width
= panelW * ratio; height = panelH * ratio;

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM