UIAchievements - jimdroberts/FishMMO GitHub Wiki
A UI control for displaying and managing achievements in the FishMMO client. Handles the display of achievement categories and descriptions, updates progress, and allows switching between categories. Integrates with the character and achievement controller to update the UI in response to game events.
-
public AchievementCategory CurrentCategory
The currently selected achievement category.
-
public RectTransform AchievementCategoryParent
The parent RectTransform for achievement category buttons.
-
public UIAchievementCategory AchievementCategoryButtonPrefab
The prefab used to instantiate achievement category buttons.
-
public RectTransform AchievementDescriptionParent
The parent RectTransform for achievement description UI elements.
-
public UIAchievementDescription AchievementDescriptionPrefab
The prefab used to instantiate achievement description UI elements.
-
public override void OnStarting()
Subscribes to character and local client events.
-
public override void OnDestroying()
Unsubscribes from events and clears all achievement UI.
-
public override void OnPostSetCharacter()
Subscribes to achievement update events after the character is set.
-
public override void OnPreUnsetCharacter()
Unsubscribes from achievement update events before the character is unset.
-
public override void OnQuitToLogin()
Clears all achievement UI when quitting to login.
-
public void AchievementController_OnUpdateAchievement(ICharacter character, Achievement achievement)
Instantiates or updates achievement UI elements when an achievement is updated.
-
public void ClearAll()
Clears all achievement UI elements and listeners.
-
public void Category_OnClick(AchievementCategory type)
Event handler for when an achievement category is clicked. Updates the visible achievements.
- Attach
UIAchievements
to an achievements UI GameObject in the Unity Editor. - Assign all required UI fields in the Inspector:
AchievementCategoryParent
,AchievementCategoryButtonPrefab
,AchievementDescriptionParent
, andAchievementDescriptionPrefab
. - Ensure the character and achievement controller systems are available and properly set up.
// Example usage in a MonoBehaviour
public UIAchievements uiAchievements;
void Start() {
uiAchievements.OnStarting();
}
// To update achievements
uiAchievements.AchievementController_OnUpdateAchievement(character, achievement);
// To switch categories
uiAchievements.Category_OnClick(AchievementCategory.Combat);
- Always assign all UI references in the Inspector to avoid null reference errors.
- Use event subscriptions in
OnStarting
/OnDestroying
to avoid memory leaks. - Keep the UI updated by calling
ClearAll()
and updating achievement lists as needed. - Integrate with the character and achievement controller for dynamic updates.