Ejemplo n.º 1
0
        void Start()
        {
            pageText = transform.Find("PageText").GetComponent <Text>();

            transform.Find("PreviousButton").GetComponent <Button>().onClick.AddListener(() => PageMove(-1));
            transform.Find("NextButton").GetComponent <Button>().onClick.AddListener(() => PageMove(1));

            baseItem = GetComponentInChildren <PageUISampleItem>();

            CreatePageItems(currentPage);
        }
Ejemplo n.º 2
0
        private void CreatePageItems(int _currentPage)
        {
            var pageItems = testItems
                            .Skip((_currentPage - 1) * countPerPage)
                            .Take(countPerPage);

            items.ForEach(x => Destroy(x));
            items.Clear();
            baseItem.gameObject.SetActive(true);
            foreach (var item in pageItems)
            {
                PageUISampleItem newItem = Instantiate(baseItem, baseItem.transform.parent);
                newItem.Init(item);
                items.Add(newItem.gameObject);
            }
            baseItem.gameObject.SetActive(false);

            pageText.text = $"{_currentPage}/{MaxPage}";
        }