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