/// <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(); } }
/// <summary> /// Raises the tooltip event. /// </summary> /// <param name="show">If set to <c>true</c> show.</param> public override void OnTooltip(bool show) { UITooltip.InstantiateIfNecessary(this.gameObject); // Handle unassigned if (!this.IsAssigned()) { // If we are showing the tooltip if (show) { UITooltip.AddTitle(UIEquipSlot.EquipTypeToString(this.m_EquipType)); UITooltip.SetHorizontalFitMode(ContentSizeFitter.FitMode.PreferredSize); UITooltip.AnchorToRect(this.transform as RectTransform); UITooltip.Show(); } else { UITooltip.Hide(); } } else { // Make sure we have spell info, otherwise game might crash if (this.m_ItemInfo == null) { return; } // If we are showing the tooltip if (show) { UIItemSlot.PrepareTooltip(this.m_ItemInfo); UITooltip.AnchorToRect(this.transform as RectTransform); UITooltip.Show(); } else { UITooltip.Hide(); } } }