protected override void OnInit(UIForm uiform, object userData) { base.OnInit(uiform, userData); m_CachedCanvas = CachedGameObject.GetOrAddComponent <Canvas>(); m_CachedCanvas.worldCamera = GameEntry.UI.UICamera; //设置UI相机 m_CachedCanvas.overrideSorting = true; OriginalDepth = m_CachedCanvas.sortingOrder; //初始深度 m_CanvasGroup = CachedGameObject.GetOrAddComponent <CanvasGroup>(); RectTransform rectTrans = CachedTransform as RectTransform; rectTrans.anchorMin = Vector2.zero; rectTrans.anchorMax = Vector2.one; rectTrans.anchoredPosition = Vector2.zero; rectTrans.sizeDelta = Vector2.zero; CachedGameObject.GetOrAddComponent <GraphicRaycaster>(); //设置所有字体 Text[] texts = GetComponentsInChildren <Text>(true); for (int i = 0; i < texts.Length; i++) { texts[i].font = s_MainFont; if (!string.IsNullOrEmpty(texts[i].text)) { texts[i].text = GameEntry.Localization.GetString(texts[i].text); } } }