//-------------------------------------- /// 初始化 //-------------------------------------- void Awake() { m_rectTransform = this.gameObject.transform as RectTransform; m_ctrlBase = transform.GetComponentInParent <UICtrlBase>(); //适配 Fit(Screen.width, Screen.height); }
protected void OnLoadComplete(GameObject go) { panelRoot = GameObject.Instantiate(go, GameUIManager.GetInstance().GetUIParent()); ctrlBase = panelRoot.GetComponent <UICtrlBase>(); if (uiType == ENUIType.UI) { // 普通UI时更新层级 UpdateLayoutLevel(); } OnLoadSuccess(); // 添加到控制层 GameUIManager.GetInstance().AddUI(this); }
//-------------------------------------- /// 计算需要修正(缩减)的宽度 //-------------------------------------- float CalculateFixedWidth(UICtrlBase ctrlBase, float screenWidth, float screenHeight) { if (ctrlBase != null && screenWidth > screenHeight * 2) { m_fixedWidth = (screenWidth * ctrlBase.m_referenceResolution.y / screenHeight) - (ctrlBase.m_referenceResolution.y * 2); if (m_fixedWidth < 0) { m_fixedWidth = 0; } } else { m_fixedWidth = 0; } return(m_fixedWidth); }