Ejemplo n.º 1
0
    void OnBtnClick(string btnName)
    {
        int Btn_index = System.Convert.ToInt32(btnName.Substring(btnName.Length - 1));

        if (prevIndex == Btn_index)
        {
            return;
        }
        else
        {
            prevIndex = Btn_index;
        }

        if (Btn_index >= 0 && Btn_index < Btn_Backs.Count)
        {
            Btn_Backs[Btn_index].normalSprite = "Symbol 31";
            if (OldClickBtn != null)
            {
                OldClickBtn.normalSprite = "Symbol 32";
            }
            OldClickBtn = Btn_Backs[Btn_index];
        }
        PlayerHeadType headtype = (PlayerHeadType)System.Convert.ToInt32(btnName.Substring(btnName.Length - 1));

        Dictionary <int, UserHeadData> head_list = HeadData[headtype];
        int index = -1;

        foreach (UserHeadData data in head_list.Values)
        {
            index++;
            if (index < list_headcell.Count)
            {
                if (!list_headcell[index].gameObject.activeSelf)
                {
                    list_headcell[index].gameObject.SetActive(true);
                }
                list_headcell[index].InitUI(data);
            }
        }
        index++;
        for (; index < list_headcell.Count; index++)
        {
            list_headcell[index].gameObject.SetActive(false);
        }

        if (list_headcell.Count > 0)
        {
            m_selHead = list_headcell[0];
            m_selHead.m_objSel.alpha = (float)System.Convert.ToUInt32(true);
        }

        m_grid.Reposition();
        _scrollView.ResetPosition();
    }
Ejemplo n.º 2
0
    //创建对象池
    void CreateElement()
    {
        HeadData = Core.Data.playerManager.HeadConfigData;
        int    MaxCount = Mathf.Max(HeadData[PlayerHeadType.Vip].Count, HeadData[PlayerHeadType.General].Count, HeadData[PlayerHeadType.Reward].Count);
        Object prefab   = PrefabLoader.loadFromPack("ZQ/UserHeadCell");

        for (int i = 0; i < MaxCount; i++)
        {
            GameObject obj = Instantiate(prefab) as GameObject;
            RED.AddChild(obj, m_grid.gameObject);
            obj.name = (10 + i).ToString();
            UserHeadCell cell = obj.GetComponent <UserHeadCell> ();
            list_headcell.Add(cell);
        }
        m_grid.Reposition();

        _scrollView.ResetPosition();
        OnBtnClick("0");
    }