Beispiel #1
0
    public static void ShowUIFromBack(Type type, Action <UiInstance> notify)
    {
        var uiInfo = GetUiInfo(type);

        if (uiInfo == null)
        {
            Debug.LogError("UI未注册,请在XUI_LIST.cs中注册:" + type.FullName);
            return;
        }

        //单例UI
        if (uiInfo.LoadType == UiLoadType.Single)
        {
            ShowInstanceUi(uiInfo, true, notify);
        }
        //非单例
        else
        {
            UiInstance.LoadUi(uiInfo, uiInfo.ViewPath, type, inst =>
            {
                inst.UiInfo = uiInfo;
                ShowUiView(inst, uiInfo.Layer);
                if (notify != null)
                {
                    notify.Invoke(inst);
                }

                inst.AfterOnShow(true);
            });
        }
    }
Beispiel #2
0
    /// <summary>
    /// 显示界面
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="notify"></param>
    public static void Show <T>(Action <T> notify = null) where T : UiInstance
    {
        var uiInfo = GetUiInfo <T>();

        if (uiInfo == null)
        {
            Debug.LogError("UI未注册,请在XUI_LIST.cs中注册:" + typeof(T).FullName);
            return;
        }

        //单例UI
        if (uiInfo.LoadType == UiLoadType.Single)
        {
            ShowInstanceUi <T>(uiInfo, false, notify);
        }
        //非单例
        else
        {
            UiInstance.LoadUi(uiInfo, uiInfo.ViewPath, typeof(T), inst =>
            {
                inst.UiInfo = uiInfo;
                ShowUiView(inst, uiInfo.Layer);
                if (notify != null)
                {
                    notify.Invoke(inst as T);
                }
                inst.AfterOnShow();
            });
        }
    }
Beispiel #3
0
    private static void ShowInstanceUi <T>(UiInfo uiInfo, bool fromBack, Action <T> notify = null, Type classType = null) where T : UiInstance
    {
        Type typeKey = classType ?? typeof(T);

        //存在缓存
        if (InstDic.ContainsKey(typeKey))
        {
            UiInstance inst = InstDic[typeKey];
            AfterLoadInstance(inst, uiInfo, fromBack, notify);
        }
        else
        {
            //已经在加载中
            bool bLoading;
            if (InstLoadState.TryGetValue(uiInfo.ViewPath, out bLoading) && bLoading)
            {
                //do noting
            }
            else
            {
                //加载
                InstLoadState[uiInfo.ViewPath] = true;
                UiInstance.LoadUi(uiInfo, uiInfo.ViewPath, typeKey, inst =>
                {
                    InstLoadState[uiInfo.ViewPath] = false;
                    InstDic[typeKey] = inst;
                    AfterLoadInstance(inst, uiInfo, fromBack, notify);
                });
            }
        }
    }