Archived on 2026-10-24. This is a historical implementation note, not current setup instructions or an active task list. Original claims, code examples, file paths, and completion statements have not all been revalidated. Use the current documentation and issue register for maintenance decisions.
Tooltip Refactoring Summary¶
Overview¶
The Tooltip system has been refactored to follow a more maintainable and scalable architecture using inheritance, mirroring the existing TooltipTrigger pattern.
Changes Made¶
1. Base Tooltip Class (Tooltip.cs)¶
- Location:
Assets/Script/App/UI/Shared/Tooltip.cs - Purpose: Contains common positioning logic shared by all tooltip types
- Features:
- Mouse positioning logic
- Selected object positioning logic
- Static positioning logic
- Update loop for handling tooltip placement
- Base fields:
isStatic,selectedObject,rectTransform
2. Tooltip_Achievement_UI (New Child Class)¶
- Location:
Assets/Script/App/UI/Shared/Tooltip_Achievement_UI.cs - Purpose: Handles achievement reward tooltips
- UI Elements:
goldText- Displays gold amountupgradeReward(List) - Displays upgrade unlock rewardscharacterReward- Displays character unlock rewards- Method:
SetAchievementText(int goldAmount, Upgrade reward_0, Upgrade reward_1, Upgrade reward_2, Character charReward)
3. Tooltip_AchievementLock_UI (New Child Class)¶
- Location:
Assets/Script/App/UI/Shared/Tooltip_AchievementLock_UI.cs - Purpose: Handles locked achievement tooltips
- UI Elements:
achievement- Contains icon, title, and description- Method:
SetAchievementLockText(string achTitle, string achDescription, Sprite achIcon)
4. Tooltip_Button_UI (New Child Class)¶
- Location:
Assets/Script/App/UI/Shared/Tooltip_Button_UI.cs - Purpose: Handles button tooltips
- UI Elements:
button(TMP_Text) - Button title text- Method:
SetToolTipText(string title, GameObject selected)
5. TooltipSystem.cs (Updated)¶
- Location:
Assets/Script/App/UI/Shared/TooltipSystem.cs - Changes: Updated field types to use the new child classes
tooltip_achis nowTooltip_Achievement_UItooltip_achLockis nowTooltip_AchievementLock_UItooltip_buttonis nowTooltip_Button_UI- API: Remains unchanged - all existing public static methods work exactly the same
Benefits of This Refactoring¶
✅ Separation of Concerns: Each tooltip type is self-contained with its own UI elements and methods ✅ Scalability: Adding new tooltip types is as simple as creating a new child class ✅ Maintainability: Easier to debug and modify specific tooltip types without affecting others ✅ Consistency: Mirrors the TooltipTrigger pattern already in use in the project ✅ Type Safety: Strong typing with specific classes instead of one monolithic class
Required Unity Editor Actions¶
1. Component Updates¶
For each tooltip GameObject in your scene, you need to update the component:
For Achievement Tooltip:
- Remove the old Tooltip component
- Add Tooltip_Achievement_UI component
- Reassign the UI element references (goldText, upgradeReward, characterReward)
For Achievement Lock Tooltip:
- Remove the old Tooltip component
- Add Tooltip_AchievementLock_UI component
- Reassign the UI element reference (achievement)
For Button Tooltip:
- Remove the old Tooltip component
- Add Tooltip_Button_UI component
- Reassign the UI element reference (button)
2. TooltipSystem GameObject References¶
In the scene where TooltipSystem is located:
- Update the tooltip_ach reference to point to the GameObject with Tooltip_Achievement_UI
- Update the tooltip_achLock reference to point to the GameObject with Tooltip_AchievementLock_UI
- Update the tooltip_button reference to point to the GameObject with Tooltip_Button_UI
No Code Changes Needed¶
The following do NOT require any changes:
- ✅ TooltipTrigger_AchievementReward.cs - Works as-is
- ✅ TooltipTrigger.cs - Works as-is
- ✅ Any code that calls TooltipSystem.ShowAchRewardTooltip() - Works as-is
- ✅ Any code that calls TooltipSystem.ShowAchLockTooltip() - Works as-is
- ✅ Any code that calls TooltipSystem.ShowButtonTooltip() - Works as-is
Adding New Tooltip Types¶
To add a new tooltip type in the future:
-
Create a new class inheriting from
Tooltip:public class Tooltip_NewType_UI : Tooltip { [Header("New Type")] public GameObject customElement; public void SetCustomText(string data) { // Your custom logic } } -
Add a new field in TooltipSystem:
public Tooltip_NewType_UI tooltip_newType; -
Add a new static method in TooltipSystem:
public static void ShowNewTypeTooltip(string data) { instance.tooltip_newType.SetCustomText(data); instance.tooltip_newType.gameObject.SetActive(true); FadeAnimation(instance.tooltip_newType.gameObject); } -
Create a new trigger class (optional but recommended):
public class TooltipTrigger_NewType : TooltipTrigger { public string customData; protected override void OnSelecting() { TooltipSystem.ShowNewTypeTooltip(customData); } }
That's it! No modification to existing tooltip types required.