示例#1
0
        void PreprocessPreload(GameObject prefab, object[] args)
        {
            Type uiType = (Type)args [0];

            if (prefab == null)
            {
                UnuLogger.LogFormatWarning("UI Error: cannot find {0}, make sure you have put UI prefab in Resources folder!", uiType.Name);
                return;
            }

            GameObject uiObj = Instantiate(prefab) as GameObject;

            uiObj.name = uiType.Name;
            uiObj.GetComponent <CanvasGroup> ().alpha = 0;

            UIManBase uiBase = uiObj.GetComponent <UIManBase> ();

            if (uiBase is UIManScreen)
            {
                uiBase.Trans.SetParent(screenRoot, false);
                uiBase.RectTrans.localScale = Vector3.one;
                if (!screenDict.ContainsKey(uiType))
                {
                    screenDict.Add(uiType, uiBase as UIManScreen);
                }
            }
            else if (uiBase is UIManDialog)
            {
                uiBase.Trans.SetParent(dialogRoot, false);
                uiBase.RectTrans.localScale = Vector3.one;
                if (!dialogDict.ContainsKey(uiType))
                {
                    dialogDict.Add(uiType, uiBase as UIManDialog);
                }
            }
            uiBase.ForceState(UIState.HIDE);
        }