public void ShowPopup(string title, string message,
                              string middleBtn, ButtonWithText.ButtonWithTextAction middleBtnCallback,
                              string leftBtn, ButtonWithText.ButtonWithTextAction leftBtnCallback,
                              string rightBtn, ButtonWithText.ButtonWithTextAction rightBtnCallback)
        {
            if (m_TitleText != null)
            {
                m_TitleText.text = title;
            }
            m_MessageText.text = message;

            if (middleBtnCallback != null)
            {
                //m_MiddleBtn.Set(middleBtn, middleBtnCallback);
                m_MiddleBtn.Set(0, middleBtn, middleBtnCallback);
                m_MiddleBtn.Show();
            }
            else
            {
                m_MiddleBtn.Hide();
            }

            if (leftBtnCallback != null)
            {
                m_LeftBtn.Set(0, leftBtn, leftBtnCallback);
                m_LeftBtn.Show();
            }
            else
            {
                m_LeftBtn.Hide();
            }

            if (rightBtnCallback != null)
            {
                //m_RightBtn.Set(rightBtn, rightBtnCallback);
                m_RightBtn.Set(0, rightBtn, rightBtnCallback);
                m_RightBtn.Show();
            }
            else
            {
                m_RightBtn.Hide();
            }
            Show();
        }
Beispiel #2
0
        /// <summary>
        /// Method to init menu
        /// </summary>
        /// <param name="data">Data to fill the scroll</param>
        public IEnumerator InitScroll(List <string> data, ButtonWithText.ButtonWithTextAction ScrollItemAction)
        {
            // Clear list elements
            ClearListElements();
            m_ListElements = new List <GameObject>();

            m_GridContent.cellSize = new Vector2(m_ContentRecTransform.rect.size.x - m_SidePadding, m_GridContent.cellSize.y);

            m_GridContent.padding.top = m_TopPadding;

            yield return(new WaitForEndOfFrame());

            // Update height of the content rect transfrom
            float hContent = (m_GridContent.cellSize.y * data.Count) + (m_GridContent.spacing.y * (data.Count - 1)) + m_GridContent.padding.top + m_GridContent.padding.bottom;

            m_ContentRecTransform.sizeDelta = new Vector2(m_ContentRecTransform.sizeDelta.x, hContent);

            yield return(new WaitForEndOfFrame());

            for (int i = 0; i < data.Count; i++)
            {
                GameObject element = Instantiate(m_ItemScrollPrefab) as GameObject;
                element.name = "Item_" + i.ToString();
                m_ListElements.Add(element);
                element.transform.parent     = m_ContentRecTransform.transform;
                element.transform.localScale = new Vector3(1, 1, 1);

                ButtonWithText scrollButton = element.GetComponent <ButtonWithText>();
                if (scrollButton != null)
                {
                    scrollButton.Set(i, data[i], ScrollItemAction);
                }
            }

            yield return(new WaitForEndOfFrame());
        }