using TMPro; using UnityEngine; using UnityEngine.UI; namespace BulletHellTemplate { /// /// Manages the icon selection and application process in the UI. /// public class IconsEntry : MonoBehaviour { [Header("UI Components")] [Tooltip("Displays the icon image.")] public Image icon; [Tooltip("Highlights the selected icon.")] public Image selected; [Tooltip("Displays the name of the icon.")] public TextMeshProUGUI iconName; private string iconId; /// /// Sets the icon information for this entry. /// /// The ID of the icon to set. public void SetIconInfo(string _iconId) { iconId = _iconId; } /// /// Applies the icon locally when clicked. This method does not synchronize with the server. /// public void OnClickChangeIcon() { PlayerSave.SetPlayerIcon(iconId); UIProfileMenu.Singleton.LoadProfile(); UIMainMenu.Singleton.LoadPlayerInfo(); UIProfileMenu.Singleton.OnChangeIcon.Invoke(); } /// /// Applies the icon locally and synchronizes the change with the server when clicked. /// public async void OnClickChangeIconOnline() { // Set the icon locally PlayerSave.SetPlayerIcon(iconId); // Update UI elements UIProfileMenu.Singleton.LoadProfile(); UIMainMenu.Singleton.LoadPlayerInfo(); // Update the icon in the Firestore database await BackendManager.Singleton.UpdatePlayerIcon(iconId); // Invoke event for successful icon change UIProfileMenu.Singleton.OnChangeIcon.Invoke(); } } }