Esempio n. 1
0
        public virtual void Show(string title, string text, Sprite icon, List <KeyValuePair <string, string> > pairs, float width, bool showBackground)
        {
            if (!string.IsNullOrEmpty(title))
            {
                this.m_Title.gameObject.SetActive(true);
                this.m_Title.text = title;
            }
            else
            {
                this.m_Title.gameObject.SetActive(false);
            }

            this.m_Text.text = text;

            if (icon != null)
            {
                this.m_Icon.overrideSprite = icon;
                this.m_Icon.transform.parent.gameObject.SetActive(true);
            }
            else
            {
                this.m_Icon.transform.parent.gameObject.SetActive(false);
            }

            if (pairs != null && pairs.Count > 0)
            {
                for (int i = 0; i < this.m_SlotCache.Count; i++)
                {
                    this.m_SlotCache[i].gameObject.SetActive(false);
                }

                while (pairs.Count > this.m_SlotCache.Count)
                {
                    CreateSlot();
                }

                for (int i = 0; i < pairs.Count; i++)
                {
                    StringPairSlot slot = this.m_SlotCache[i];
                    slot.gameObject.SetActive(true);
                    slot.Target = pairs[i];
                }
                this.m_SlotParent.gameObject.SetActive(true);
            }
            else
            {
                this.m_SlotParent.gameObject.SetActive(false);
            }
            m_RectTransform.sizeDelta = new Vector2(width, m_RectTransform.sizeDelta.y);

            this.m_Background.gameObject.SetActive(showBackground);

            Show();
        }
Esempio n. 2
0
        protected virtual StringPairSlot CreateSlot()
        {
            if (this.m_SlotPrefab != null)
            {
                GameObject go = (GameObject)Instantiate(this.m_SlotPrefab.gameObject);
                go.SetActive(true);
                go.transform.SetParent(this.m_SlotParent, false);
                StringPairSlot slot = go.GetComponent <StringPairSlot>();
                this.m_SlotCache.Add(slot);

                return(slot);
            }
            Debug.LogWarning("[Tooltip] Please ensure that the slot prefab is set in the inspector.");
            return(null);
        }