Esempio n. 1
0
 /// <summary>
 /// Updates the option text effect.
 /// </summary>
 /// <param name="gObject">G object.</param>
 private void UpdateTextEffect(GameObject gObject)
 {
     // Update text text effect
     if (this.m_OptionTextEffect == TextEffectType.Shadow)
     {
         Shadow s = gObject.GetComponent <Shadow>();
         if (s == null)
         {
             s = gObject.AddComponent <Shadow>();
         }
         s.effectColor     = this.m_OptionTextEffectColor;
         s.effectDistance  = this.m_OptionTextEffectDistance;
         s.useGraphicAlpha = this.m_OptionTextEffectUseGraphicAlpha;
     }
     else if (this.m_OptionTextEffect == TextEffectType.Outline)
     {
         NicerOutline o = gObject.GetComponent <NicerOutline>();
         if (o == null)
         {
             o = gObject.AddComponent <NicerOutline>();
         }
         o.effectColor     = this.m_OptionTextEffectColor;
         o.effectDistance  = this.m_OptionTextEffectDistance;
         o.useGraphicAlpha = this.m_OptionTextEffectUseGraphicAlpha;
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Adds the option text effect.
 /// </summary>
 /// <param name="gObject">G object.</param>
 private void AddTextEffect(GameObject gObject)
 {
     // Add new text effect
     if (this.m_OptionTextEffect == TextEffectType.Shadow)
     {
         Shadow s = gObject.AddComponent <Shadow>();
         s.effectColor     = this.m_OptionTextEffectColor;
         s.effectDistance  = this.m_OptionTextEffectDistance;
         s.useGraphicAlpha = this.m_OptionTextEffectUseGraphicAlpha;
     }
     else if (this.m_OptionTextEffect == TextEffectType.Outline)
     {
         NicerOutline o = gObject.AddComponent <NicerOutline>();
         o.effectColor     = this.m_OptionTextEffectColor;
         o.effectDistance  = this.m_OptionTextEffectDistance;
         o.useGraphicAlpha = this.m_OptionTextEffectUseGraphicAlpha;
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Rebuilds the options text effects.
        /// </summary>
        public void RebuildTextEffects()
        {
            // Loop through the options
            foreach (GameObject optionObject in this.m_OptionGameObjects)
            {
                Text text = optionObject.GetComponentInChildren <Text>();

                if (text != null)
                {
                    Shadow       s = text.gameObject.GetComponent <Shadow>();
                    NicerOutline o = text.gameObject.GetComponent <NicerOutline>();

                    // Destroy any effect we find
                    if (Application.isPlaying)
                    {
                        if (s != null)
                        {
                            Destroy(s);
                        }
                        if (o != null)
                        {
                            Destroy(o);
                        }
                    }
                    else
                    {
                        if (s != null)
                        {
                            DestroyImmediate(s);
                        }
                        if (o != null)
                        {
                            DestroyImmediate(o);
                        }
                    }

                    // Re-add the effect
                    this.AddTextEffect(text.gameObject);
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Adds a chat message to the specified tab.
        /// </summary>
        /// <param name="tabId">The tab id.</param>
        /// <param name="text">The message.</param>
        public void ReceiveChatMessage(int tabId, string text)
        {
            TabInfo tabInfo = this.GetTabInfo(tabId);

            // Make sure we have tab info
            if (tabInfo == null || tabInfo.content == null)
            {
                return;
            }

            // Create the text line
            GameObject obj = new GameObject("Text " + tabInfo.content.childCount.ToString(), typeof(RectTransform));

            // Prepare the game object
            obj.layer = this.gameObject.layer;

            // Get the rect transform
            RectTransform rectTransform = (obj.transform as RectTransform);

            // Prepare the rect transform
            rectTransform.localScale = new Vector3(1f, 1f, 1f);
            rectTransform.pivot      = new Vector2(0f, 1f);
            rectTransform.anchorMin  = new Vector2(0f, 1f);
            rectTransform.anchorMax  = new Vector2(0f, 1f);

            // Set the parent
            rectTransform.SetParent(tabInfo.content, false);

            // Add the text component
            Text textComp = obj.AddComponent <Text>();

            // Prepare the text component
            textComp.font        = this.m_TextFont;
            textComp.fontSize    = this.m_TextFontSize;
            textComp.lineSpacing = this.m_TextLineSpacing;
            textComp.color       = this.m_TextColor;
            textComp.text        = text;

            // Prepare the text effect
            if (this.m_TextEffect != TextEffect.None)
            {
                switch (this.m_TextEffect)
                {
                case TextEffect.Shadow:
                    Shadow shadow = obj.AddComponent <Shadow>();
                    shadow.effectColor    = this.m_TextEffectColor;
                    shadow.effectDistance = this.m_TextEffectDistance;
                    break;

                case TextEffect.Outline:
                    NicerOutline outline = obj.AddComponent <NicerOutline>();
                    outline.effectColor    = this.m_TextEffectColor;
                    outline.effectDistance = this.m_TextEffectDistance;
                    break;
                }
            }

            // Rebuild the content layout
            LayoutRebuilder.ForceRebuildLayoutImmediate(tabInfo.content as RectTransform);

            // Scroll to bottom
            this.OnScrollToBottomClick();
        }