Пример #1
0
        public void SetItems(ListItemContainer itemContainer)
        {
            if (itemContainer.items.Count > 20)
            {
                Debug.LogWarning("Creating a lot of buttons for " + name + ". This may impact performance." +
                                 "(No testing done, but now would be a good time to do that.)");
            }

            int panelIndex = 0;

            for (int i = 0; i < itemContainer.items.Count; ++i)
            {
                PanelItemButton actButton = Instantiate(actionButtonPrefab, contentContainers[panelIndex].transform).GetComponent <PanelItemButton>();
                actButton.GetComponent <PanelItemButton>().SetButton(itemContainer.items[i]);
                actButton.gameObject.SetActive(true);
                activeButtons[panelIndex].Add(actButton);

                if (itemContainer != null && itemContainer == itemContainer.items[i])
                {
                    selectedPanel = panelIndex;
                    selectedRow   = activeButtons[panelIndex].Count - 1;
                }

                if (++panelIndex >= contentContainers.Length)
                {
                    panelIndex = 0;
                }
            }

            buttonSize   = ((RectTransform)activeButtons[0][0].transform).rect.size;
            viewportSize = viewport.rect.size;

            StartCoroutine(DelayedSelectionChange());
        }
Пример #2
0
 /// <summary>
 /// position is center point of panel relative to parent object.
 /// </summary>
 /// <param name="items"></param>
 /// <param name="position"></param>
 public void OpenPanel(ListItemContainer items, Vector2 position)
 {
     gameObject.SetActive(true);
     listItemContainer            = items;
     this.transform.localPosition = position
                                    + new Vector2(-((RectTransform)transform).rect.size.x, ((RectTransform)transform).rect.size.y) * .5f;
     panelTitle.text = items.name;
     buttonPanel.SetItems(items);
     StartCoroutine(OpenAnimation());
 }