Beispiel #1
0
        void AddItems()
        {
            int length = dataLength;

            for (int i = 0; i < length; i++)
            {
                GameObject pageGo = pageObjectPool.GetObject();
                pageGo.name = i.ToString();
                pageGo.transform.SetParent(pageContent, false);
                GameObject dotGo = dotObjectPool.GetObject();
                dotGo.name = i.ToString();
                dotGo.transform.SetParent(dotContent, false);

                Toggle dotToggle = dotGo.GetComponent <Toggle>();
                if (dotToggle != null)
                {
                    dotToggle.group = _dotToggleGroup;
                    dotToggle.isOn  = i == 0 ? true : false;
                }

                UIBaseCell pageCell = pageGo.GetComponent <UIBaseCell>();
                pageCell.data  = _datas[i];
                pageCell.index = i;
            }

            dotContent.gameObject.SetActive(length > 1);
            pageScrollRect.enabled = length > 1;
            pageScrollRect.content.anchoredPosition = Vector2.zero;
        }
        void AddItems()
        {
            int length = dataLength;

            for (int i = 0; i < length; i++)
            {
                GameObject tabGo = tabPool.GetObject();
                tabGo.name = i.ToString();
                tabGo.transform.SetParent(tabContentPanel, false);
                GameObject pageGo = pagePool.GetObject();
                pageGo.name = i.ToString();
                pageGo.transform.SetParent(pageContentPanel, false);

                Toggle tabToggle = tabGo.GetComponent <Toggle>();
                if (tabToggle != null)
                {
                    tabToggle.group = _tabToggleGroup;
                    tabToggle.onValueChanged.AddListener(TabOnChange);
                    tabToggle.isOn = !_init && i == 0 ? true : false;
                }

                UIBaseCell tabCell  = tabGo.GetComponent <UIBaseCell>();
                UIBaseCell pageCell = pageGo.GetComponent <UIBaseCell>();
                tabCell.data   = _datas[i];
                tabCell.index  = i;
                pageCell.data  = _datas[i];
                pageCell.index = i;
            }

            // jump to specific tab
            if (_jumpIndex >= 0 && !_init)
            {
                iTweenUtils.CreateTimeout(gameObject, delegate()
                {
                    SetTab(_jumpIndex);
                    ScrollToTab(_jumpIndex);
                    _jumpIndex = -1;
                }, 0.5f, "UITabPageList_ScrollToTab");
            }

            // forbid scroll if tab count less than tabSizeInPanel
            if (length <= tabSizeInPanel)
            {
                _tabScrollRect.enabled = false;
            }
            else
            {
                _tabScrollRect.enabled = true;
            }

            _tabScrollRect.content.anchoredPosition  = Vector2.zero;
            _pageScrollRect.content.anchoredPosition = Vector2.zero;

            _init = length > 0;
        }
 void RemovePages()
 {
     while (content.childCount > 0)
     {
         GameObject toRemove = content.transform.GetChild(0).gameObject;
         UIBaseCell baseCell = toRemove.GetComponent <UIBaseCell>();
         baseCell.data  = null;
         baseCell.index = 0;
         objectPool.ReturnObject(toRemove);
     }
 }
 private void UpdateNewCell(Transform go, int index)
 {
     if (m_Datas != null && index >= 0 && index < m_Datas.Count)
     {
         UIBaseCell cell = go.GetComponent <UIBaseCell>();
         if (cell != null)
         {
             cell.index = index;
             cell.data  = m_Datas[index];
         }
     }
 }
Beispiel #5
0
        private void DeleteCell(int index)
        {
            GameObject toRemove = contentPanel.transform.GetChild(index).gameObject;

            UIBaseCell baseCell = toRemove.GetComponent <UIBaseCell>();

            if (baseCell != null)
            {
                baseCell.data  = null;
                baseCell.index = 0;
            }

            objectPool.ReturnObject(toRemove);
        }
Beispiel #6
0
        private UIBaseCell CreateCell(int index)
        {
            GameObject cellGo = objectPool.GetObject();

            cellGo.transform.SetParent(contentPanel, false);

            UIBaseCell baseCell = cellGo.GetComponent <UIBaseCell>();

            if (baseCell != null)
            {
                baseCell.data  = _datas[index];
                baseCell.index = index;
            }

            return(baseCell);
        }
Beispiel #7
0
        void RemoveItems()
        {
            while (currentPageCount > 0)
            {
                GameObject toRemove = pageContent.GetChild(0).gameObject;
                UIBaseCell baseCell = toRemove.GetComponent <UIBaseCell>();
                baseCell.data  = null;
                baseCell.index = 0;
                pageObjectPool.ReturnObject(toRemove);
            }

            while (dotContent.childCount > 0)
            {
                GameObject toRemove = dotContent.GetChild(0).gameObject;
                UIBaseCell baseCell = toRemove.GetComponent <UIBaseCell>();
                baseCell.data  = null;
                baseCell.index = 0;
                dotObjectPool.ReturnObject(toRemove);
            }
        }
        void RemoveItems()
        {
            while (tabContentPanel.childCount > 0)
            {
                GameObject toRemove = tabContentPanel.GetChild(0).gameObject;
                UIBaseCell baseCell = toRemove.GetComponent <UIBaseCell>();
                baseCell.data  = null;
                baseCell.index = 0;
                tabPool.ReturnObject(toRemove);
            }

            while (pageContentPanel.childCount > 0)
            {
                GameObject toRemove = pageContentPanel.GetChild(0).gameObject;
                UIBaseCell baseCell = toRemove.GetComponent <UIBaseCell>();
                baseCell.data  = null;
                baseCell.index = 0;
                pagePool.ReturnObject(toRemove);
            }
        }
        void AddPages()
        {
            _fanPageList.Clear();

            int length = _data != null ? _data.Length : 0;

            for (int i = 0; i < length; i++)
            {
                object     pageData = _data[i];
                GameObject pageGo   = objectPool.GetObject();
                pageGo.transform.SetParent(content, false);

                _fanPageList.Add(pageGo);

                UIBaseCell baseCell = pageGo.GetComponent <UIBaseCell>();
                baseCell.data  = pageData;
                baseCell.index = i;
            }

            StartCoroutine(CalculatePagePositionAndAngle());
        }