Пример #1
0
    /// <summary>
    /// 检查是否隐藏UI
    /// </summary>
    void CheckHidenWin()
    {
        bool isHiden = false;

        for (int i = m_IdPosList.Count - 1; i >= 0; i--)
        {
            int id = m_IdPosList[i];
            if (m_UIList.ContainsKey(id))
            {
                WindowBase winbs = m_UIList[id];
                if (winbs == null)
                {
                    continue;
                }
                T_UIConfig config = winbs.F_GetUIConfig();
                if (config.UI_Type == T_UIConfig.UI_TYPE.WIN)
                {
                    if (isHiden == true)
                    {
                        TransformUtil.ChangeLayer(winbs.transform, 0, 5);
                    }
                    else
                    {
                        TransformUtil.ChangeLayer(winbs.transform, 5, 0);
                    }

                    if (config.ShowMask == (int)MaskType.BlurTexture || config.ShowMask == (int)MaskType.HidenUnderUI)
                    {
                        isHiden = true;
                    }
                }
            }
        }
    }
Пример #2
0
    void LoadAssetComplete(string sourceName, GameObject Obj)
    {
        //UIdata data = tdata as UIdata;
        UIdata     data       = null;
        GameObject gameobject = Obj;

        if (gameobject == null)
        {
            Loger.Error("Instantiate  failed " + data.config.Prefab);
        }
        gameobject.transform.SetParent(GetParent(data.config.UI_Type));
        gameobject.transform.localScale    = Vector3.one;
        gameobject.transform.localRotation = Quaternion.identity;
        gameobject.layer = LayerMask.NameToLayer("UI");
        int count = GetCountByUIType(data.config.UI_Type);

        gameobject.transform.localPosition = new Vector3(0, 0, m_StartDepth * (int)data.config.UI_Type + count * m_depth);

        //检测是否添加Canvas
        CheckCanvas(gameobject);

        //检测是否添加配置表对应的Script
        WindowBase wdbase = clazzAdder.AddClazz(gameobject, data.config.Script);

        //初始化
        wdbase.F_SetId(data.id, data.config.E_ui, data.config.UI_Type);
        if (m_DataModule.ContainsKey(data.id) && m_DataModule[data.id] == data)
        {
            m_DataModule[data.id].windowBase = wdbase;
            m_UIList.Add(data.id, wdbase);
            m_EUIToIdDec[data.config.E_ui].Add(data.id);

            try
            {
                wdbase.F_InitPos();
                wdbase.F_OnInit();
                wdbase.F_IsInit();
                wdbase.RegisterEvent();
                wdbase.F_OnData(data.obj);
                wdbase.F_AddSound();
            }
            catch (Exception e)
            {
                Loger.Error(e);
            }
        }
        else
        {
            Unload(wdbase);
        }

        //设置深度
        ResetDepth(data.config.UI_Type);
        //是否添加遮罩
        SetFullScreenMask((MaskType)data.config.ShowMask);
        TransformUtil.ChangeLayer(wdbase.transform, 5, 0);
        //回调
        if (data.onComplete != null)
        {
            data.onComplete(wdbase);
        }
    }
Пример #3
0
    /// <summary>
    /// 显示界面;
    /// </summary>
    /// <param name="eUI">配置表ID</param>
    /// <param name="obj">参的参数</param>
    /// <param name="onComplete">完成回调函数</param>
    public void F_ShowUI(T_UIConfig.E_UI eUI, object obj = null, ActionOnComplete onComplete = null)
    {
        if (this.IsOpenUI != null && !this.IsOpenUI.Invoke(eUI))
        {
            return;
        }

        T_UIConfig config = GetConfigData(eUI);

        if (config.ShowMask == (int)MaskType.BlurTexture)
        {
            F_BlurScreenShot();
        }
        //使用已经打开的UI
        if (config.MoreOpen == false && m_EUIToIdDec.ContainsKey(eUI))
        {
            List <int> idlist = m_EUIToIdDec[eUI];
            if (idlist.Count > 0)
            {
                WindowBase wdb = m_UIList[idlist[0]];
                //如果需要背景模糊,得先处理再打开界面;
                wdb.gameObject.SetActive(true);
                wdb.RegisterEvent();
                wdb.F_OnData(obj);
                wdb.F_AddSound();
                //置顶
                MoveToTop(eUI);
                SetFullScreenMask();
                TransformUtil.ChangeLayer(wdb.transform, 5, 0);
                //回调
                if (onComplete != null)
                {
                    onComplete(wdb);
                }
                //设置Clear类型
                //ResMgr.GetInstance().SetClearType(wdb.gameObject, clear);
            }
            return;
        }

        if ((MaskType)config.ShowMask == MaskType.BlackMask)
        {
            setFullScreenTop();
        }

        //初始化新的UI
        if (!m_EUIToIdDec.ContainsKey(eUI))
        {
            List <int> ids = new List <int>();
            m_EUIToIdDec.Add(eUI, ids);
        }
        //生成Id
        int id = buildId();

        m_IdPosList.Add(id);

        UIdata data = new UIdata();

        data.id         = id;
        data.config     = config;
        data.obj        = obj;
        data.onComplete = onComplete;
        m_DataModule.Add(id, data);

        if (data.config.IsShowLoading)
        {
            UIManager.F_GetInstance().F_ShowUI(T_UIConfig.E_UI.TIP_SHOW_LOADING);
        }
        AssetBundleManager.GetInstance().Load(config.Prefab, EnResourceType.UI, EnLoadPrority.UI, LoadAssetComplete);
    }