Ejemplo n.º 1
0
    void SetItemDisplay(bool isRebuild = false)
    {
        if (content == null)
        {
            throw new Exception("SetItemDisplay Exception: content is null !");
        }

        //计算已显示的哪些需要隐藏
        for (int i = 0; i < m_items.Count; i++)
        {
            m_items[i].OnDrag();

            //已经完全离开了显示区域
            if (!m_viewBounds.Intersects(GetItemBounds(m_items[i].m_index)))
            {
                ReusingScrollItemBase itemTmp = m_items[i];
                m_items.Remove(itemTmp);
                itemTmp.OnHide();

                if (!isRebuild)
                {
                    //隐藏并移到缓存
                    itemTmp.gameObject.SetActive(false);
                }
                m_itemCaches.Add(itemTmp);

                m_indexList[itemTmp.m_index].status = ReusingStatus.Hide;
            }
        }

        //计算出哪些需要显示
        //如果有未显示的则显示出来,从对象池取出对象
        bool m_clip = false;

        for (int i = 0; i < m_indexList.Count; i++)
        {
            if (m_indexList[i].status == ReusingStatus.Hide)
            {
                if (m_viewBounds.Intersects(GetItemBounds(m_indexList[i].index)))
                {
                    ShowItem(i, isRebuild, m_datas[i]);


                    m_indexList[i].status = ReusingStatus.Show;
                    m_clip = true;
                }
                else
                {
                    if (m_clip)
                    {
                        break;
                    }
                }
            }
            else
            {
                m_clip = true;
            }
        }
    }
Ejemplo n.º 2
0
 static int GetItem(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         ReusingScrollRect obj = (ReusingScrollRect)ToLua.CheckObject(L, 1, typeof(ReusingScrollRect));
         int arg0 = (int)LuaDLL.luaL_checknumber(L, 2);
         ReusingScrollItemBase o = obj.GetItem(arg0);
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Ejemplo n.º 3
0
    void ShowItem(int index, Dictionary <string, object> data)
    {
        ReusingScrollItemBase itemTmp = GetItem();

        itemTmp.transform.SetParent(content);
        itemTmp.transform.localScale = Vector3.one;

        itemTmp.SetConetnt(index, data);

        itemTmp.m_RectTransform.pivot     = GetPivot();
        itemTmp.m_RectTransform.anchorMin = GetMinAchors();
        itemTmp.m_RectTransform.anchorMax = GetMaxAchors();

        itemTmp.m_RectTransform.anchoredPosition3D = GetItemPos(index);

        itemTmp.m_index = index;
    }
Ejemplo n.º 4
0
    ReusingScrollItemBase GetItem()
    {
        ReusingScrollItemBase result = null;

        if (m_itemCatchs.Count > 0)
        {
            result = m_itemCatchs[0];
            result.gameObject.SetActive(true);
            m_itemCatchs.RemoveAt(0);

            m_items.Add(result);
            return(result);
        }

        result = GameObjectManager.CreatGameObjectByPool(m_itemPrefab).GetComponent <ReusingScrollItemBase>();
        result.Init();
        m_items.Add(result);

        return(result);
    }
Ejemplo n.º 5
0
    ReusingScrollItemBase GetItem()
    {
        ReusingScrollItemBase result = null;

        if (m_itemCaches.Count > 0)
        {
            result = m_itemCaches[0];
            result.gameObject.SetActive(true);
            result.OnShow();
            m_itemCaches.RemoveAt(0);

            m_items.Add(result);
            return(result);
        }

        result = GameObjectManager.Instance.CreatePoolObject(m_ItemName).GetComponent <ReusingScrollItemBase>();
        result.Init(m_items.Count);
        m_items.Add(result);

        return(result);
    }
Ejemplo n.º 6
0
    void SetItemDisplay()
    {
        m_clip = false;
        //计算已显示的哪些需要隐藏
        for (int i = 0; i < m_items.Count; i++)
        {
            if (!m_clip)
            {
                m_startPos = m_items[i].m_index;
                m_clip     = true;
            }
            else
            {
                if (m_startPos > m_items[i].m_index)
                {
                    m_startPos = m_items[i].m_index;
                }
            }

            //已经完全离开了显示区域
            if (!m_viewBounds.Intersects(GetItemBounds(m_items[i].m_index)))
            {
                ReusingScrollItemBase itemTmp = m_items[i];
                m_items.Remove(itemTmp);

                //隐藏并移到缓存
                itemTmp.gameObject.SetActive(false);
                m_itemCatchs.Add(itemTmp);

                m_indexList[itemTmp.m_index].status = ReusingStatus.Hide;
            }
        }

        if (m_startPos > 0)
        {
            m_startPos--;
        }

        //Debug.Log(m_startPos);

        m_clip = false;

        //计算出哪些需要显示
        //如果有未显示的则显示出来,从对象池取出对象
        for (int i = m_startPos; i < m_indexList.Count; i++)
        {
            if (m_indexList[i].status == ReusingStatus.Hide)
            {
                if (m_viewBounds.Intersects(GetItemBounds(m_indexList[i].index)))
                {
                    ShowItem(i, m_datas[i]);
                    m_indexList[i].status = ReusingStatus.Show;
                    m_clip = true;
                }
                else
                {
                    if (m_clip)
                    {
                        break;
                    }
                }
            }
            else
            {
                m_clip = true;
            }
        }
    }