// 初始化 public bool Start() { m_canvas = GetComponent <Canvas>(); InitUICamera(); InitLayer(); m_raycaster = GetComponent <GraphicRaycaster>(); m_wndList = new Dictionary <WndID, IUIWnd>(); m_messageList = new Dictionary <WndMsgID, List <IUIWnd> >(); m_keyMessageList = new Dictionary <FuntionShortCutSlotIndex, List <IUIWnd> > [(int)KeyStatus.Max]; for (int i = 0; i < m_keyMessageList.Length; ++i) { m_keyMessageList[i] = new Dictionary <FuntionShortCutSlotIndex, List <IUIWnd> >(); } if (Instance == null) { // 单独调试场景,不创建其他窗口 Instance = this; return(true); } //删除载入等待UI GameObject waitingloadUI = GameObject.Find("Canvas"); if (waitingloadUI) { DestroyImmediate(waitingloadUI, true); } foreach (IUIWnd wnd in UWindowWnd.CreateWindowWnd())//CreateAllWindow()) { WndID id = wnd.GetID(); if (m_wndList.ContainsKey(id)) { Debug.LogError("UISystem 重复初始化窗口, id=" + id); return(false); } if ((wnd.GetLoadMask() & (int)WndLoadMaskDef.WND_LoadMask_All) != 0 && (wnd.GetPermissionMask() & (int)WndPermissionMaskDef.WND_PM_All) != 0) { if (!wnd.InitFinish() && wnd.Init() == false) { Debug.LogError("UISystem 窗口初始化失败, id=" + id); return(false); } } m_wndList[id] = wnd; } #region 字体花屏处理 Font.textureRebuilt += OnFontTextureRebuilt; System.Type fontUpdateTrackerType = typeof(UnityEngine.UI.FontUpdateTracker); m_RebuildForFont = fontUpdateTrackerType.GetMethod("RebuildForFont", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static); #endregion return(true); }