/// <summary>
 /// Sets the lines template.
 /// </summary>
 /// <param name="lines">Lines template.</param>
 public static void SetLines(UITooltipLines lines)
 {
     if (mInstance != null)
         mInstance.Internal_SetLines(lines);
 }
 /// <summary>
 /// Adds a new double column line.
 /// </summary>
 /// <param name="leftContent">Left content.</param>
 /// <param name="rightContent">Right content.</param>
 /// <param name="padding">The line padding.</param>
 /// <param name="style">The line style.</param>
 public static void AddLine(string leftContent, string rightContent, RectOffset padding, UITooltipLines.LineStyle style)
 {
     if (mInstance != null)
         mInstance.Internal_AddLine(leftContent, rightContent, padding, style);
 }
        /// <summary>
        /// Adds title line.
        /// </summary>
        /// <param name="title">Tooltip title.</param>
        protected virtual void Internal_AddTitle(string title)
        {
            // Make sure we have a template initialized
            if (this.m_LinesTemplate == null)
                this.m_LinesTemplate = new UITooltipLines();

            // Add the title line
            this.m_LinesTemplate.AddLine(title, new RectOffset(0, 0, 0, 0), UITooltipLines.LineStyle.Title);
        }
        /// <summary>
        /// Adds description line.
        /// </summary>
        /// <param name="description">Tooltip description.</param>
        protected virtual void Internal_AddDescription(string description)
        {
            // Make sure we have a template initialized
            if (this.m_LinesTemplate == null)
                this.m_LinesTemplate = new UITooltipLines();

            // Add the description line
            this.m_LinesTemplate.AddLine(description, new RectOffset(0, 0, 6, 0), UITooltipLines.LineStyle.Description);
        }
        /// <summary>
        /// Adds a column (Either to the last line if it's not complete or to a new one).
        /// </summary>
        /// <param name="a">Content.</param>
        protected void Internal_AddLineColumn(string a)
        {
            // Make sure we have a template initialized
            if (this.m_LinesTemplate == null)
                this.m_LinesTemplate = new UITooltipLines();

            // Add the column
            this.m_LinesTemplate.AddColumn(a);
        }
        /// <summary>
        /// Adds a new double column line.
        /// </summary>
        /// <param name="a">Left content.</param>
        /// <param name="b">Right content.</param>
        /// <param name="padding">The line padding.</param>
        /// <param name="style">The line style.</param>
        protected void Internal_AddLine(string a, string b, RectOffset padding, UITooltipLines.LineStyle style)
        {
            // Make sure we have a template initialized
            if (this.m_LinesTemplate == null)
                this.m_LinesTemplate = new UITooltipLines();

            // Add the line
            this.m_LinesTemplate.AddLine(a, b, padding, style);
        }
 /// <summary>
 /// Sets the lines template.
 /// </summary>
 /// <param name="lines">Lines template.</param>
 protected void Internal_SetLines(UITooltipLines lines)
 {
     this.m_LinesTemplate = lines;
 }
        /// <summary>
        /// Does a line cleanup.
        /// </summary>
        protected virtual void CleanupLines()
        {
            // Clear out the line objects
            foreach (Transform t in this.transform)
            {
                // If the component is not part of the layout dont destroy it
                if (t.gameObject.GetComponent<LayoutElement>() != null)
                {
                    if (t.gameObject.GetComponent<LayoutElement>().ignoreLayout)
                        continue;
                }

                Destroy(t.gameObject);
            }

            // Clear out the attributes template
            this.m_LinesTemplate = null;
        }
        /// <summary>
        /// Creates new line column object.
        /// </summary>
        /// <param name="parent">Parent.</param>
        /// <param name="content">Content.</param>
        /// <param name="isLeft">If set to <c>true</c> is left.</param>
        /// <param name="style">The style.</param>
        private void CreateLineColumn(Transform parent, string content, bool isLeft, UITooltipLines.LineStyle style)
        {
            // Create the game object
            GameObject obj = new GameObject("Column", typeof(RectTransform), typeof(CanvasRenderer));
            obj.layer = this.gameObject.layer;
            obj.transform.SetParent(parent);

            // Set the pivot to top left
            (obj.transform as RectTransform).pivot = new Vector2(0f, 1f);

            // Set a fixed size for attribute columns
            if (style == UITooltipLines.LineStyle.Attribute)
            {
                VerticalLayoutGroup vlg = this.gameObject.GetComponent<VerticalLayoutGroup>();
                HorizontalLayoutGroup phlg = parent.gameObject.GetComponent<HorizontalLayoutGroup>();
                LayoutElement le = obj.AddComponent<LayoutElement>();
                le.preferredWidth = (this.m_Rect.sizeDelta.x - vlg.padding.horizontal - phlg.padding.horizontal) / 2f;
            }

            // Prepare the text component
            Text text = obj.AddComponent<Text>();
            text.text = content;
            text.supportRichText = true;
            text.alignment = (isLeft) ? TextAnchor.LowerLeft : TextAnchor.LowerRight;

            // Prepare some style properties
            TextEffectType effect = TextEffectType.None;
            Color effectColor = Color.white;
            Vector2 effectDistance = new Vector2(1f, -1f);
            bool effectUseAlpha = true;

            switch (style)
            {
                case UITooltipLines.LineStyle.Title:
                    text.font = this.m_TitleFont;
                    text.fontStyle = this.m_TitleFontStyle;
                    text.fontSize = this.m_TitleFontSize;
                    text.lineSpacing = this.m_TitleFontLineSpacing;
                    text.color = this.m_TitleFontColor;
                    effect = this.m_TitleTextEffect;
                    effectColor = this.m_TitleTextEffectColor;
                    effectDistance = this.m_TitleTextEffectDistance;
                    effectUseAlpha = this.m_TitleTextEffectUseGraphicAlpha;
                    break;
                case UITooltipLines.LineStyle.Attribute:
                    text.font = this.m_AttributeFont;
                    text.fontStyle = this.m_AttributeFontStyle;
                    text.fontSize = this.m_AttributeFontSize;
                    text.lineSpacing = this.m_AttributeFontLineSpacing;
                    text.color = this.m_AttributeFontColor;
                    effect = this.m_AttributeTextEffect;
                    effectColor = this.m_AttributeTextEffectColor;
                    effectDistance = this.m_AttributeTextEffectDistance;
                    effectUseAlpha = this.m_AttributeTextEffectUseGraphicAlpha;
                    break;
                case UITooltipLines.LineStyle.Description:
                    text.font = this.m_DescriptionFont;
                    text.fontStyle = this.m_DescriptionFontStyle;
                    text.fontSize = this.m_DescriptionFontSize;
                    text.lineSpacing = this.m_DescriptionFontLineSpacing;
                    text.color = this.m_DescriptionFontColor;
                    effect = this.m_DescriptionTextEffect;
                    effectColor = this.m_DescriptionTextEffectColor;
                    effectDistance = this.m_DescriptionTextEffectDistance;
                    effectUseAlpha = this.m_DescriptionTextEffectUseGraphicAlpha;
                    break;
            }

            // Add text effect component
            if (effect == TextEffectType.Shadow)
            {
                Shadow s = obj.AddComponent<Shadow>();
                s.effectColor = effectColor;
                s.effectDistance = effectDistance;
                s.useGraphicAlpha = effectUseAlpha;
            }
            else if (effect == TextEffectType.Outline)
            {
                Outline o = obj.AddComponent<Outline>();
                o.effectColor = effectColor;
                o.effectDistance = effectDistance;
                o.useGraphicAlpha = effectUseAlpha;
            }
        }