예제 #1
0
    public void PushOne(Action action, MFUIManager.MFUIID baseUI = MFUIManager.MFUIID.None,
                        uint pri = 0, string debugText = "")
    {
        MFUIQueueUnit unit = new MFUIQueueUnit()
        {
            UnitID       = ++m_nextUnitID,
            act          = action,
            UnitPriority = pri,
            BaseUIID     = baseUI
        };

        if (baseUI == MFUIManager.MFUIID.None)
        {
            MFUIUtils.MFUIDebug(string.Concat(debugText, " Run 1"));
            unit.JustDoIt();
        }
        else if (baseUI == MFUIManager.CurrentUI && !IsLocking)
        {
            MFUIUtils.MFUIDebug(string.Concat(debugText, " Run 2"));
            unit.JustDoIt();
        }
        else
        {
            MFUIUtils.MFUIDebug(string.Concat(debugText, " Run 3"));
            m_listUI.Add(unit);

            m_listUI = m_listUI.OrderByDescending(t => t.UnitPriority).ToList();
        }
    }
예제 #2
0
    private void SwitchUI(MFUIID targetUIID, MFUIID baseUIID              = MFUIID.None, uint pri = 0, bool isAttached = false,
                          MFUISwitchAnim.MFUISwitchAnimType switchInType  = MFUISwitchAnim.MFUISwitchAnimType.None,
                          MFUISwitchAnim.MFUISwitchAnimType switchOutType = MFUISwitchAnim.MFUISwitchAnimType.None)
    {
        if (CurrentUI == targetUIID)
        {
            return;
        }

        if (!DictUIIDToOBj.ContainsKey(targetUIID))
        {
            MFUIUtils.MFUIDebug("MFUIID Dictionary not contain Obj");
            return;
        }

        if (switchOutType != MFUISwitchAnim.MFUISwitchAnimType.None)
        {
            MFUISwitchAnimNode[] animNodeArr = DictUIIDToOBj[CurrentUI].GetComponentsInChildren <MFUISwitchAnimNode>(true);

            if (animNodeArr.Length > 0)
            {
                animNodeArr[0].Play(switchOutType);
            }
            else
            {
                DictUIIDToOBj[CurrentUI].AddComponent <MFUISwitchAnimNode>().Play(switchOutType);
            }
        }

        if (switchInType != MFUISwitchAnim.MFUISwitchAnimType.None)
        {
            MFUISwitchAnimNode[] animNodeArr = DictUIIDToOBj[targetUIID].GetComponentsInChildren <MFUISwitchAnimNode>(true);

            if (animNodeArr.Length > 0)
            {
                animNodeArr[0].Play(switchInType);
            }
            else
            {
                DictUIIDToOBj[targetUIID].AddComponent <MFUISwitchAnimNode>().Play(switchInType);
            }
        }

        //DictUIIDToOBj[CurrentUI].MFUIgameObject.GetComponentsInChildren<MFUISwitchAnimNode>(true)[0].Play(switchOutType);
        //DictUIIDToOBj[targetUIID].MFUIgameObject.GetComponentsInChildren<MFUISwitchAnimNode>(true)[0].Play(switchInType);
        //Debug.LogError(CurrentUI);
        //if (DictUIIDToOBj.ContainsKey(CurrentUI) && !isAttached)
        //{
        //    DictUIIDToOBj[CurrentUI].GetComponentsInChildren<MFUIUnit>(true)[0].Hide();
        //    //Debug.LogError(CurrentUI + " Hide");
        //}



        if (DictUIIDToOBj[targetUIID].GetComponentsInChildren <MFUIUnit>(true)[0].IsUIDirty())
        {
            DictUIIDToOBj[targetUIID].GetComponentsInChildren <MFUIUnit>(true)[0].Show();
        }
        //Debug.LogError(targetUIID + " Show");
    }
예제 #3
0
    public void RegisterGameObjectList(List <MFUIResourceReqInfo> list, System.Action callBack = null, bool preLoad = false)
    {
        for (int i = 0; i < list.Count; ++i)
        {
            if (!m_dictUIIDToUnInstanceObjCount.ContainsKey(list[i].id))
            {
                m_dictUIIDToUnInstanceObjCount.Add(list[i].id, 1);
            }
            else
            {
                ++m_dictUIIDToUnInstanceObjCount[list[i].id];
            }
        }

        for (int i = 0; i < list.Count; ++i)
        {
            if (m_dictGoNameToUIID.ContainsKey(list[i].goName))
            {
                MFUIUtils.MFUIDebug("Same GameObject Name Registered now will Replace it !");
            }

            m_dictGoNameToUIID[list[i].goName] = list[i].id;
            m_dictUIIDToCallBack[list[i].id]   = callBack;

            RegisterGameObject(list[i].id, list[i].path, list[i].goName, preLoad);
        }
    }
예제 #4
0
 private static void AddWigetToFullNameData(string widgetName, string fullName)
 {
     if (m_widgetToFullName.ContainsKey(widgetName))
     {
         MFUIUtils.MFUIDebug("Same Key In the WidgetName to FullName Dict ,Now Replace It!");
     }
     //m_widgetToFullName.Add(widgetName, fullName);
     m_widgetToFullName[widgetName] = fullName;
 }
예제 #5
0
    public override void CallWhenCreate()
    {
        MFUIUtils.MFUIDebug("Register CityMainUI");
        RegisterButtonHandler("TestPanel1itemButton");

        SetLabelText("TestPanel1itemName", "EquipmentName");
        SetSpriteImage("TestPanel1itemImage", "NGUI");
        SetButtonClickHandler("TestPanel1itemButton", OnItemButtonClick);
        SetButtonPressHandler("TestPanel1itemButton", OnItemButtonPress);
        SetButtonDragHandler("TestPanel1itemButton", OnItemButtonDrag);
    }
예제 #6
0
    public MFUIButtonHandler GetButtonHandler(string name)
    {
        if (!m_dictButtonAction.ContainsKey(name))
        {
            MFUIUtils.MFUIDebug(string.Concat(name, " is not found in ClickAction Dict , now Return Null instead"));

            return(null);
        }
        else
        {
            return(m_dictButtonAction[name]);
        }
    }
예제 #7
0
    public UITexture GetTexture(string name)
    {
        if (!m_dictTexture.ContainsKey(name))
        {
            MFUIUtils.MFUIDebug(string.Concat(name, " is not found in TextrueDict , now Return Null instead"));

            return(null);
        }
        else
        {
            return(m_dictTexture[name]);
        }
    }
예제 #8
0
    public UISprite GetSprite(string name)
    {
        if (!m_dictSprite.ContainsKey(name))
        {
            MFUIUtils.MFUIDebug(string.Concat(name, " is not found in SpriteDict , now Return Null instead"));

            return(null);
        }
        else
        {
            return(m_dictSprite[name]);
        }
    }
예제 #9
0
    public UILabel GetLabel(string name)
    {
        if (!m_dictLabel.ContainsKey(name))
        {
            MFUIUtils.MFUIDebug(string.Concat(name, " is not found in LabelDict , now Return Null instead"));

            return(null);
        }
        else
        {
            return(m_dictLabel[name]);
        }
    }
예제 #10
0
    public Transform GetTransform(string name)
    {
        if (!m_dictTransform.ContainsKey(name))
        {
            MFUIUtils.MFUIDebug(string.Concat(name, " is not found in TransformDict , now Return Null instead"));

            return(null);
        }
        else
        {
            return(m_dictTransform[name]);
        }
    }
예제 #11
0
    public void SetLabelText(string name, string text)
    {
        if (!m_dictLabel.ContainsKey(name))
        {
            MFUIUtils.MFUIDebug(string.Concat(name, " is not found in labelDict , SetLabelText Failed!"));

            return;
        }
        else
        {
            m_dictLabel[name].text = text;
        }
    }
예제 #12
0
    public void SetSpriteImage(string name, string imgName)
    {
        if (!m_dictSprite.ContainsKey(name))
        {
            MFUIUtils.MFUIDebug(string.Concat(name, " is not found in spriteDict , SetSpriteImage Failed!"));

            return;
        }
        else
        {
            m_dictSprite[name].spriteName = imgName;
        }
    }
예제 #13
0
    public void SetButtonDragHandler(string name, Action <Vector2, int> dragHandler)
    {
        if (!m_dictButtonAction.ContainsKey(name))
        {
            MFUIUtils.MFUIDebug(string.Concat(name, " is not found in Draghandler Dict , SetButtonDragHandler Failed !"));

            return;
        }
        else
        {
            m_dictButtonAction[name].DragHandler = dragHandler;
        }
    }
예제 #14
0
    public void SetButtonPressHandler(string name, Action <bool, int> pressHandler)
    {
        if (!m_dictButtonAction.ContainsKey(name))
        {
            MFUIUtils.MFUIDebug(string.Concat(name, " is not found in PressHandler Dict , SetButtonPressHandler Failed !"));

            return;
        }
        else
        {
            m_dictButtonAction[name].PressHandler = pressHandler;
        }
    }
예제 #15
0
    public void SetTexture(string name, Texture tex)
    {
        if (!m_dictTexture.ContainsKey(name))
        {
            MFUIUtils.MFUIDebug(string.Concat(name, " is not found in textureDict , SetTexture Failed!"));

            return;
        }
        else
        {
            m_dictTexture[name].mainTexture = tex;
        }
    }
예제 #16
0
    public void RegisterUI(MFUIID UIID, GameObject obj)
    {
        if (obj == null)
        {
            MFUIUtils.MFUIDebug("Register Obj is null");
            return;
        }

        if (DictUIIDToOBj.ContainsKey(UIID))
        {
            MFUIUtils.MFUIDebug("UIID is AlReady In the Dict , now Will Replace it !");
        }

        DictUIIDToOBj[UIID] = obj;
    }
예제 #17
0
 public void CheckUIQueue()
 {
     for (int i = 0; i < m_listUI.Count; ++i)
     {
         if (m_listUI[i].BaseUIID == MFUIManager.CurrentUI)
         {
             if (!IsLocking)
             {
                 MFUIUtils.MFUIDebug("CheckUIQueue Got One !!!");
                 m_listUI[i].JustDoIt();
                 m_listUI.Remove(m_listUI[i]);
                 break;
             }
         }
     }
 }
예제 #18
0
    void Create()
    {
        //foreach (var item in m_dictTransform)
        //{
        //    Debug.LogError(item.Value.name);
        //}
        CallWhenCreate();

        if (LogicUnit == null)
        {
            MFUIUtils.MFUIDebug("Not Attach LogicUnit ! ");
            return;
        }

        //Debug.Log(m_myGameObject.name);
        LogicUnit.FillBufferedData();
    }
예제 #19
0
    public UILabel RegisterLabel(string name, Transform rootTran = null)
    {
        UILabel lbl;

        if (m_dictLabel.ContainsKey(name))
        {
            MFUIUtils.MFUIDebug(string.Concat(name, " is Already in the Label Dict ! Now Instead it of this !"));
        }

        if (rootTran == null)
        {
            lbl = m_myTransform.Find(MFUIUtils.GetFullName(name)).GetComponentsInChildren <UILabel>(true)[0];
        }
        else
        {
            lbl = rootTran.Find(name).GetComponentsInChildren <UILabel>(true)[0];
        }

        m_dictLabel[name] = lbl;

        return(lbl);
    }
예제 #20
0
    public UISprite RegisterSprite(string name, Transform rootTran = null)
    {
        UISprite sp;

        if (m_dictSprite.ContainsKey(name))
        {
            MFUIUtils.MFUIDebug(string.Concat(name, " is Already in the Sprite Dict ! Now Instead it of this !"));
        }

        if (rootTran == null)
        {
            sp = m_myTransform.Find(MFUIUtils.GetFullName(name)).GetComponentsInChildren <UISprite>(true)[0];
        }
        else
        {
            sp = rootTran.Find(name).GetComponentsInChildren <UISprite>(true)[0];
        }

        m_dictSprite[name] = sp;

        return(sp);
    }
예제 #21
0
    public UITexture RegisterTexture(string name, Transform rootTran = null)
    {
        UITexture tex;

        if (m_dictTexture.ContainsKey(name))
        {
            MFUIUtils.MFUIDebug(string.Concat(name, " is Already in the Texture Dict ! Now Instead it of this !"));
        }

        if (rootTran == null)
        {
            tex = m_myTransform.Find(MFUIUtils.GetFullName(name)).GetComponentsInChildren <UITexture>(true)[0];
        }
        else
        {
            tex = rootTran.Find(name).GetComponentsInChildren <UITexture>(true)[0];
        }

        m_dictTexture[name] = tex;

        return(tex);
    }
예제 #22
0
    public MFUIButtonHandler RegisterButtonHandler(string name, Transform rootTran = null)
    {
        MFUIButtonHandler bh;

        if (m_dictButtonAction.ContainsKey(name))
        {
            MFUIUtils.MFUIDebug(string.Concat(name, " is Already in the buttonHandler Dict ! Now Instead it of this !"));
        }

        if (rootTran == null)
        {
            bh = m_myTransform.Find(MFUIUtils.GetFullName(name)).GetComponentsInChildren <MFUIButtonHandler>(true)[0];
        }
        else
        {
            bh = rootTran.Find(name).GetComponentsInChildren <MFUIButtonHandler>(true)[0];
        }

        m_dictButtonAction[name] = bh;

        return(bh);
    }
예제 #23
0
    public void LoadInstance(MFUIManager.MFUIID id, string path, string goName, bool preLoad) //加载资源并实例化
    {
        if (m_dictResNameToObj.ContainsKey(path))
        {
            MFUIGameObjectPoolUnit unit = new MFUIGameObjectPoolUnit();
            unit.isFree        = false;
            unit.poolUnit      = (GameObject)(GameObject.Instantiate(m_dictResNameToObj[path]));
            unit.poolUnit.name = goName;

            if (preLoad)
            {
                unit.isFree = true;
                MFUIUtils.ShowGameObject(false, unit.poolUnit);
            }

            MFUIGameObjectPool.GetSingleton().m_listResPathToPoolUnit[path].Add(unit);

            MFUIGameObjectPool.GetSingleton().ResourceLoaded(goName);
        }
        else
        {
            AssetCacheMgr.GetUIResource(path, (obj) =>
            {
                if (obj == null)
                {
                    MFUIUtils.MFUIDebug(string.Concat(path, " Not Found ! "));
                    return;
                }

                if (m_dictResNameToObj.ContainsKey(path))
                {
                    MFUIUtils.MFUIDebug("Same Key in ResNameToObj Dict , Now Replace It");
                }
                //m_dictResNameToObj.Add(path, obj);
                m_dictResNameToObj[path] = obj;

                if (!m_dictUIIDToObjList.ContainsKey(id))
                {
                    m_dictUIIDToObjList.Add(id, new List <Object>());
                }

                if (!m_dictUIIDToObjList[id].Contains(obj))
                {
                    m_dictUIIDToObjList[id].Add(obj);
                }

                MFUIGameObjectPoolUnit unit = new MFUIGameObjectPoolUnit();
                unit.isFree        = false;
                unit.poolUnit      = (GameObject)(GameObject.Instantiate(m_dictResNameToObj[path]));
                unit.poolUnit.name = goName;

                if (preLoad)
                {
                    unit.isFree = true;
                    MFUIUtils.ShowGameObject(false, unit.poolUnit);
                }

                MFUIGameObjectPool.GetSingleton().m_listResPathToPoolUnit[path].Add(unit);

                MFUIGameObjectPool.GetSingleton().ResourceLoaded(goName);
            });
            //Object obj = Resources.Load(path);

            //if (obj == null)
            //{
            //    MFUIUtils.MFUIDebug(string.Concat(path, " Not Found ! "));
            //    return;
            //}
            //m_dictResNameToObj.Add(path, obj);

            //MFUIGameObjectPoolUnit unit = new MFUIGameObjectPoolUnit();
            //unit.isFree = false;
            //unit.poolUnit = (GameObject)(GameObject.Instantiate(m_dictResNameToObj[path]));
            //unit.poolUnit.name = goName;

            //MFUIGameObjectPool.GetSingleton().m_listResPathToPoolUnit[path].Add(unit);

            //MFUIGameObjectPool.GetSingleton().ResourceLoaded(goName);
        }
    }
예제 #24
0
    private void FillDefaultWidget(Transform rootTransform)
    {
        if (rootTransform == null)
        {
            return;
        }

        UIWidget[] widgetArr = null;

        widgetArr = rootTransform.GetComponentsInChildren <UILabel>(true);

        for (int i = 0; i < widgetArr.Length; ++i)
        {
            if (m_dictLabel.ContainsKey(widgetArr[i].name))
            {
                MFUIUtils.MFUIDebug(string.Concat(widgetArr[i].name, " is Already in the Label Dict ! Now Instead it of this !"));
            }

            m_dictLabel[widgetArr[i].name] = (UILabel)widgetArr[i];
        }

        widgetArr = rootTransform.GetComponentsInChildren <UISprite>(true);

        for (int i = 0; i < widgetArr.Length; ++i)
        {
            if (m_dictSprite.ContainsKey(widgetArr[i].name))
            {
                MFUIUtils.MFUIDebug(string.Concat(widgetArr[i].name, " is Already in the Sprite Dict ! Now Instead it of this !"));
            }

            m_dictSprite[widgetArr[i].name] = (UISprite)widgetArr[i];
        }

        widgetArr = rootTransform.GetComponentsInChildren <UITexture>(true);

        for (int i = 0; i < widgetArr.Length; ++i)
        {
            if (m_dictTexture.ContainsKey(widgetArr[i].name))
            {
                MFUIUtils.MFUIDebug(string.Concat(widgetArr[i].name, " is Already in the Texture Dict ! Now Instead it of this !"));
            }

            m_dictTexture[widgetArr[i].name] = (UITexture)widgetArr[i];
        }

        Transform[] transArr = null;

        transArr = rootTransform.GetComponentsInChildren <Transform>(true);

        for (int i = 0; i < transArr.Length; ++i)
        {
            if (m_dictLabel.ContainsKey(transArr[i].name) || m_dictSprite.ContainsKey(transArr[i].name))
            {
                continue;
            }
            else if (m_dictTransform.ContainsKey(transArr[i].name))
            {
                MFUIUtils.MFUIDebug(string.Concat(transArr[i].name, " is Already in the Transform Dict ! Now Instead it of this !"));
            }

            m_dictTransform[transArr[i].name] = transArr[i];
        }

        //if (widgetArr.Length > 0)
        //{
        //    if (m_dictLabel.ContainsKey(rootTransform.name))
        //    {
        //        MFUIUtils.MFUIDebug(string.Concat(name, " is Already in the Label Dict ! Now Instead it of this !"));
        //    }

        //    m_dictLabel[rootTransform.name] = (UILabel)widgetArr[0];
        //}

        //widgetArr = rootTransform.GetComponentsInChildren<UISprite>(true);

        //if (widgetArr.Length > 0)
        //{
        //    if (m_dictSprite.ContainsKey(rootTransform.name))
        //    {
        //        MFUIUtils.MFUIDebug(string.Concat(name, " is Already in the Sprite Dict ! Now Instead it of this !"));
        //    }

        //    m_dictSprite[rootTransform.name] = (UISprite)widgetArr[0];
        //}
    }