using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; /// /// Class to display user info in the ChangeUserScreen scene /// public class UserCard : MonoBehaviour { /// /// Reference to the userlist /// public UserList userList; /// /// User to upload info into this card /// public User user; /// /// Callback to the UpdateSelection in the ChangeUserScreen /// public UnityAction selectUser; /// /// Callback to the update hte users container in the ChangeUserScreen scene /// public UnityAction updateUserCardContainer; /// /// Callback to display an error message in the ChangeUserScreen scene /// public UnityAction displayError; /// /// UI reference to the selectio button /// public Button button; /// /// UI reference to the avatar /// public Image avatar; /// /// UI reference to the username /// public TMP_Text username; /// /// Start is called before the first frame update /// void Start() { avatar.sprite = user.avatar; username.text = user.username; button.onClick.AddListener(selectUser); } /// /// Delete the user from the userlist /// public void DeleteUser() { if (userList.DeleteUser(user)) { // User is removed, update and save userList.Save(); updateUserCardContainer(); } else { // User is not removed, display an error displayError(); } } }