using TMPro; using UnityEngine; using UnityEngine.UI; namespace BulletHellTemplate { /// /// Manages the frame selection and application process in the UI. /// public class FramesEntry : MonoBehaviour { [Header("UI Components")] [Tooltip("Displays the frame image.")] public Image icon; [Tooltip("Highlights the selected frame.")] public Image selected; [Tooltip("Displays the name of the frame.")] public TextMeshProUGUI frameName; private string frameId; /// /// Sets the frame information for this entry. /// /// The ID of the frame to set. public void SetFrameInfo(string _frameId) { frameId = _frameId; } /// /// Applies the frame locally when clicked. This method does not synchronize with the server. /// public void OnClickChangeFrame() { PlayerSave.SetPlayerFrame(frameId); UIProfileMenu.Singleton.LoadProfile(); UIMainMenu.Singleton.LoadPlayerInfo(); UIProfileMenu.Singleton.OnChangeFrame.Invoke(); } /// /// Applies the frame locally and synchronizes the change with the server when clicked. /// public async void OnClickChangeFrameOnline() { // Set the frame locally PlayerSave.SetPlayerFrame(frameId); // Update UI elements UIProfileMenu.Singleton.LoadProfile(); UIMainMenu.Singleton.LoadPlayerInfo(); // Update the frame in the Firestore database await BackendManager.Singleton.UpdatePlayerFrame(frameId); // Invoke event for successful frame change UIProfileMenu.Singleton.OnChangeFrame.Invoke(); } } }