Esempio n. 1
0
        /// <summary>
        /// Raises the tooltip event.
        /// </summary>
        /// <param name="show">If set to <c>true</c> show.</param>
        public virtual void OnTooltip(bool show)
        {
            if (!this.enabled || !this.IsActive())
            {
                return;
            }

            // If we are showing the tooltip
            if (show)
            {
                UITooltip.InstantiateIfNecessary(this.gameObject);

                for (int i = 0; i < this.m_ContentLines.Length; i++)
                {
                    UITooltipLineContent line = this.m_ContentLines[i];

                    if (line.IsSpacer)
                    {
                        UITooltip.AddSpacer();
                    }
                    else
                    {
                        if (line.LineStyle != UITooltipLines.LineStyle.Custom)
                        {
                            UITooltip.AddLine(line.Content, line.LineStyle);
                        }
                        else
                        {
                            UITooltip.AddLine(line.Content, line.CustomLineStyle);
                        }
                    }
                }

                if (this.m_WidthMode == WidthMode.Preferred)
                {
                    UITooltip.SetHorizontalFitMode(ContentSizeFitter.FitMode.PreferredSize);
                }

                // Anchor to this slot
                if (this.m_Position == Position.Anchored)
                {
                    UITooltip.AnchorToRect(this.transform as RectTransform);
                }

                // Handle offset override
                if (this.m_OverrideOffset)
                {
                    UITooltip.OverrideOffset(this.m_Offset);
                    UITooltip.OverrideAnchoredOffset(this.m_Offset);
                }

                // Show the tooltip
                UITooltip.Show();
            }
            else
            {
                // Hide the tooltip
                UITooltip.Hide();
            }
        }