Пример #1
0
        private void CreateInitializingPanel(out GameObject panelClone, out RectTransform panelCloneRect)
        {
            panelClone = Instantiate(buttonPanelPrefab);
            panelClone.transform.SetParent(canvas.transform, false);
            panelClone.transform.SetParent(transform);

            panelCloneRect = panelClone.GetComponent <RectTransform>();
            RectTransform thisRect = GetComponent <RectTransform>();

            RectTransformExtensions.SetLeft(panelCloneRect, thisRect.offsetMax.x);
            RectTransformExtensions.SetRight(panelCloneRect, thisRect.offsetMax.x);
        }
Пример #2
0
        private void LoadPanels(int numberOfPages)
        {
            for (int i = 0; i <= numberOfPages - 1; i++)
            {
                GameObject panel = Instantiate(buttonPanelPrefab) as GameObject;
                panel.transform.SetParent(canvas.transform, false);
                panel.transform.SetParent(transform);

                RectTransform panelCloneRect = panel.GetComponent <RectTransform>();

                RectTransformExtensions.SetLeft(panelCloneRect, thisRect.offsetMax.x);
                RectTransformExtensions.SetRight(panelCloneRect, thisRect.offsetMax.x);

                panel.GetComponent <RectTransform>().localPosition = new Vector2(panelRect.width * (i), 0);

                int numberOfButtons = i == numberOfPages - 1 ? numberOfLevels - levelCount : numberPerPage;
                LoadButtons(numberOfButtons, panel);
            }
        }