Skip to content

Commit

Permalink
Add HideTooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
AnhPham committed Feb 6, 2025
1 parent 4e02c24 commit 8319aa5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -556,9 +556,16 @@ public Transform button;
```

```cs
// targetY is the distance from the start position along the Y axis
ScreenManager.ShowTooltip(text: "Tooltip Text", worldPosition: button.position, targetY: 100f);
```

Hide the tooltip

```cs
ScreenManager.HideTooltip();
```

<h3>9. Other useful methods of ScreenManager</h3>

<h4>9.1. Top </h4>
Expand Down
19 changes: 19 additions & 0 deletions SSv5/Assets/ThirdParties/SS/Screen/Scripts/ScreenManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,17 @@ public static void ShowTooltip(string text, Vector3 worldPosition, float targetY

m_Instance.LoadAndShowTooltip(text, worldPosition, targetY);
}

/// <summary>
/// Hide Tooltip
/// </summary>
public static void HideTooltip()
{
if (m_Instance == null)
return;

m_Instance.HideTooltipImmediately();
}
#endregion

#region Unity Functions
Expand Down Expand Up @@ -1215,5 +1226,13 @@ private void LoadAndShowTooltip(string text, Vector3 worldPosition, float target
CreateAndShowTooltip(tooltipPrefab, text, worldPosition, targetY);
#endif
}

private void HideTooltipImmediately()
{
if (m_Tooltip != null)
{
m_Tooltip.HideToolTip();
}
}
#endregion
}

0 comments on commit 8319aa5

Please sign in to comment.