Esempio n. 1
0
        private void loadUIForm(UIConfigData uiInfo, string uiFormName)
        {
            Transform parent = null;

            switch ((UIFormDepth)uiInfo.UIFormsDepth)
            {
            case UIFormDepth.Normal: parent = m_TraNormal; break;

            case UIFormDepth.Fixed: parent = m_TraFixed; break;

            case UIFormDepth.PopUp: parent = m_TraPopUp; break;

            case UIFormDepth.Notice: parent = m_TraNotice; break;
            }

            UIParam uiParam = new UIParam();

            uiParam.uIFormDepth    = (UIFormDepth)uiInfo.UIFormsDepth;
            uiParam.uIFormShowMode = (UIFormShowMode)uiInfo.UIFormShowMode;

            if ((LoadType)uiInfo.LandType == LoadType.Resources)
            {
                GameObject prefab = ResoucesMgr.Instance.Load <GameObject>(uiInfo.ResourcesPath, false);
                loadUIFormFinish(uiFormName, prefab, parent, uiParam);
            }
            else if ((LoadType)uiInfo.LandType == LoadType.AssetBundle)
            {
                AssetBundleMgr.Instance.LoadAssetBunlde("UI", uiInfo.AssetBundlePath);
                GameObject prefab = AssetBundleMgr.Instance.LoadAsset("UI", uiInfo.AssetBundlePath, uiInfo.AssetName) as GameObject;
                loadUIFormFinish(uiFormName, prefab, parent, uiParam);
            }
        }
Esempio n. 2
0
        private void LoadUIForm(UIConfigData uiInfo, string uiFormName)
        {
            Transform parent = null;

            switch ((UIFormDepth)uiInfo.UIFormsDepth)
            {
            case UIFormDepth.Normal: parent = traNormal; break;

            case UIFormDepth.Fixed: parent = traFixed; break;

            case UIFormDepth.PopUp: parent = traPopUp; break;

            case UIFormDepth.Notice: parent = traNotice; break;
            }

            UIParam uiParam = new UIParam();

            uiParam.UIFormsDepth    = (UIFormDepth)uiInfo.UIFormsDepth;
            uiParam.UIFormsShowMode = (UIFormShowMode)uiInfo.UIFormShowMode;

            if ((LoadType)uiInfo.LandType == LoadType.Resources)
            {
                GameObject prefab = ResoucesMgr.Instance.Load <GameObject>(uiInfo.ResourcesPath, false);
                LoadUIFormFinish(uiFormName, prefab, parent, uiParam);
            }
            else if ((LoadType)uiInfo.LandType == LoadType.AssetBundle)
            {
                AbParam abParam = new AbParam();
                abParam.SceneName = "UI";
                abParam.AbName    = uiInfo.AssetBundlePath;
                abParam.AssetName = uiInfo.AssetName;
                AssetManager.Instance.LoadAsset(abParam, (error, asset) =>
                {
                    if (string.IsNullOrEmpty(error))
                    {
                        LoadUIFormFinish(uiFormName, asset as GameObject, parent, uiParam);
                    }
                    else
                    {
                        LoadUIFormFinish(uiFormName, null, parent, uiParam);
                    }
                });
            }
        }
Esempio n. 3
0
        private void loadUIFormFinish(string uiFormName, GameObject prefab, Transform parent, UIParam uiParam)
        {
            if (prefab == null)
            {
                if (m_DicAllUIForms.ContainsKey(uiFormName))
                {
                    m_DicAllUIForms.Remove(uiFormName);
                }
                Debug.LogWarning(GetType() + "/loadUIForm()/ load ui error! uiFormName:" + uiFormName);
                return;
            }

            GameObject item = Instantiate(prefab, parent);

            item.name = uiFormName;

            UIFormItem uIFormItem = item.GetComponent <UIFormItem>();

            if (uIFormItem == null)
            {
                uIFormItem = item.AddComponent <UIFormItem>();
            }
            uIFormItem.CurrentUIParam   = uiParam;
            m_DicAllUIForms[uiFormName] = uIFormItem;

            Type type = Type.GetType(uiFormName);

            if (type != null && item.GetComponent <BaseUIForm>() == null)
            {
                item.AddComponent(type);
            }

            BaseUIForm baseUIForm = item.GetComponent <BaseUIForm>();

            if (baseUIForm != null)
            {
                baseUIForm.uIFormsDepth   = uIFormItem.CurrentUIParam.uIFormDepth;
                baseUIForm.uIFormShowMode = uIFormItem.CurrentUIParam.uIFormShowMode;
            }

            if (!m_DicOpenUIForms.ContainsKey(uiFormName))
            {
                openUIForm(uiFormName);
            }
        }
Esempio n. 4
0
        private void LoadUIFormFinish(string uiFormName, GameObject prefab, Transform parent, UIParam uiParam)
        {
            if (prefab == null)
            {
                if (dicAllUIForms.ContainsKey(uiFormName))
                {
                    dicAllUIForms.Remove(uiFormName);
                }
                Debug.LogWarning(GetType() + "/LoadUIForm()/ load ui error! uiFormName:" + uiFormName);
                return;
            }

            GameObject item = Instantiate(prefab, parent);

            item.name = uiFormName;

            UIFormItem uIFormItem = item.GetComponent <UIFormItem>();

            if (uIFormItem == null)
            {
                uIFormItem = item.AddComponent <UIFormItem>();
            }
            uIFormItem.CurrentUIParam = uiParam;
            dicAllUIForms[uiFormName] = uIFormItem;

            Type type = Type.GetType(uiFormName);

            if (type != null && item.GetComponent <BaseUIForm>() == null)
            {
                item.AddComponent(type);
            }

            BaseUIForm baseUIForm = item.GetComponent <BaseUIForm>();

            if (baseUIForm != null)
            {
                baseUIForm.OnOpenUI();
            }

            item.SetActive(true);
            if (!dicOpenUIForms.ContainsKey(uiFormName))
            {
                dicOpenUIForms.Add(uiFormName, uIFormItem);
            }
        }