Ejemplo n.º 1
0
    private float CalculateMoveDistance()
    {
        float totalDis = 0.0f;

        if (_seletedTrans != null)
        {
            float diffPos = Mathf.Abs(m_Content.anchoredPosition.y);

            int movedCount = (int)(diffPos / cellInternal);

            for (int idx = 0; idx < movedCount; ++idx)
            {
                m_Content.GetChild(0).SetAsLastSibling();
            }
            m_Content.anchoredPosition = new Vector2(0, m_Content.anchoredPosition.y - movedCount * cellInternal);

            SlotGridLayout tmplayout = layout as SlotGridLayout;
            if (tmplayout)
            {
                tmplayout.ForceLayout();
            }
            UpdateBounds();

            int sidx = _seletedTrans.GetSiblingIndex();


            if (sidx == 0)
            {
                totalDis  = m_Content.childCount * cellInternal - m_Content.anchoredPosition.y;
                totalDis += layout.spacing.y * 1;
            }
            else
            {
                totalDis = sidx * cellInternal - m_Content.anchoredPosition.y + layout.spacing.y;
            }

            //Debug.Log(transform.name + " TotoalDis=" + totalDis + " sidx=" + sidx + "m_Content.anchoredPosition.y=" + m_Content.anchoredPosition.y + " value=" + _seletedTrans.Find("Text").GetComponent<Text>().text);
        }
        else
        {
            Debug.LogError("selected is null");
        }

        return(totalDis);
    }
Ejemplo n.º 2
0
    private void CheckHiddenItems()
    {
        if (isNotUpdateValue)
        {
            return;
        }

        bIsDealing = true;

        int     childs = m_Content.childCount;
        Vector2 pos    = m_Content.anchoredPosition;

        int idx       = 0;
        int movedLine = 0;

        if (bMoveToEnd)
        {
            //calculate the begin idx
            for (int i = 0; i < triggerHideEventLimit; ++i)
            {
                for (idx = 0; idx < layout.constraintCount; ++idx)
                {
                    m_Content.GetChild(0).SetAsLastSibling();
                }
                movedLine++;
            }

            if (horizontal)
            {
                pos.x += cellInternal * movedLine;
            }
            else
            {
                pos.y -= cellInternal * movedLine;
            }
        }
        else
        {
            for (int i = 0; i < triggerHideEventLimit; ++i)
            {
                for (idx = layout.constraintCount - 1; idx >= 0; --idx)
                {
                    Transform trans = m_Content.GetChild(childs - 1);
                    trans.SetAsFirstSibling();
                }
                movedLine++;
            }
            if (horizontal)
            {
                pos.x -= cellInternal * movedLine;
            }
            else if (vertical)
            {
                pos.y += cellInternal * movedLine;
            }
        }
        m_PrevPosition             = pos;
        m_Content.anchoredPosition = pos;

        SlotGridLayout tmpLayout = layout as SlotGridLayout;

        if (tmpLayout != null)
        {
            tmpLayout.ForceLayout();
        }
        bIsDealing = false;
    }
Ejemplo n.º 3
0
    private void CheckHiddenItems()
    {
        if (isNotUpdateValue)
        {
            return;
        }

        bIsDealing = true;

        int childs = m_Content.childCount;
        Vector2 pos = m_Content.anchoredPosition;

        int idx = 0;
        int movedLine = 0;
        if (bMoveToEnd)
        {
            //calculate the begin idx       
            for (int i = 0; i < triggerHideEventLimit; ++i)
            {

                if (m_bIsRegister)
                {

                    for (idx = 0; idx < layout.constraintCount; ++idx)
                    {
                        Transform trans = m_Content.GetChild(0);
                        trans.SetAsLastSibling();
                        trans.gameObject.SetActive(false);
                    }
                    movedLine++;
                    m_rendercount--;
                }
                else
                {
                    if (currentEndLine + 1 < m_pages.Count)
                    {
                        currentEndLine++;
                        currentStartLine++;
                        List<object> data = m_pages[currentEndLine];
                        for (idx = 0; idx < layout.constraintCount; ++idx)
                        {
                            Transform trans = m_Content.GetChild(0);

                            if (idx < data.Count)
                            {
                                trans.gameObject.SetActive(true);
                                trans.GetComponent<SlotItemInfo>().info = data[idx];
                            }
                            else
                            {
                                if (bHideBlankItem)
                                {
                                    trans.gameObject.SetActive(false);
                                }
                                else
                                {
                                    trans.gameObject.SetActive(true);
                                    trans.GetComponent<SlotItemInfo>().info = null;
                                }
                            }
                            trans.SetAsLastSibling();

                        }

                        movedLine++;
                    }
                }
               
            }

            if (horizontal)
            {
                pos.x += cellInternal * movedLine;
            }
            else
            {
                pos.y -= cellInternal * movedLine;
            }
        }
        else
        {
            for (int i = 0; i < triggerHideEventLimit; ++i)
            {

                if (currentStartLine - 1 >= 0)
                {
                    currentStartLine -= 1;
                    currentEndLine -= 1;
                    List<object> data = m_pages[currentStartLine];
                    for (idx = layout.constraintCount - 1; idx >= 0; --idx)
                    {   
                        Transform trans = m_Content.GetChild(childs - 1);
                        if(idx >= data.Count)
                        {
                            if (bHideBlankItem == true)
                            {
                                trans.gameObject.SetActive(false);
                            }
                            else
                            {
                                trans.GetComponent<SlotItemInfo>().info = null;
                            }
                        }
                        else
                        {
                            trans.gameObject.SetActive(true);
                            trans.GetComponent<SlotItemInfo>().info = m_pages[currentStartLine][idx];
                        }
                        trans.SetAsFirstSibling();
                    }
                    movedLine++;
                }

            }
            if (horizontal)
            {
                pos.x -= cellInternal * movedLine;
            }
            else if (vertical)
            {
                pos.y += cellInternal * movedLine;
            }
        }
        m_PrevPosition = pos;
        m_Content.anchoredPosition = pos;
        UpdateBounds();
        UpdatePrevData();

        SlotGridLayout tmpLayout = layout as SlotGridLayout;
        if (tmpLayout != null)
        {
            tmpLayout.ForceLayout();
        }
        bIsDealing = false;
    }