66 lines
1.5 KiB
C#
66 lines
1.5 KiB
C#
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
using UnityEngine.UI;
|
|
|
|
/// <summary>
|
|
/// Handles actions when a user presses the account button (upper left corner)
|
|
/// </summary>
|
|
public class UserButton : MonoBehaviour
|
|
{
|
|
/// <summary>
|
|
/// Reference to the user list, so we can extract the current user
|
|
/// </summary>
|
|
public UserList userList;
|
|
|
|
/// <summary>
|
|
/// UI reference to the avatar object
|
|
/// </summary>
|
|
public Image avatar;
|
|
|
|
/// <summary>
|
|
/// UI reference to the username object
|
|
/// </summary>
|
|
public TMP_Text username;
|
|
|
|
/// <summary>
|
|
/// UI reference to the dropdown box with all options
|
|
/// </summary>
|
|
public GameObject dropdownBox;
|
|
|
|
/// <summary>
|
|
/// Start is called before the first frame update
|
|
/// </summary>
|
|
void Start()
|
|
{
|
|
User user = userList.GetCurrentUser();
|
|
avatar.sprite = user.avatar;
|
|
username.text = user.username;
|
|
dropdownBox.SetActive(false);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Change to the UserProgressScreen scene
|
|
/// </summary>
|
|
public void OpenProgressCallback()
|
|
{
|
|
SceneManager.LoadScene("Accounts/Scenes/UserProgressScreen");
|
|
}
|
|
|
|
/// <summary>
|
|
/// Change to the ChangeUserScreen scene
|
|
/// </summary>
|
|
public void ChangeUserCallback()
|
|
{
|
|
SceneManager.LoadScene("Accounts/Scenes/ChangeUserScreen");
|
|
}
|
|
|
|
/// <summary>
|
|
/// Toggle the dropdown box
|
|
/// </summary>
|
|
public void ToggleDropdown()
|
|
{
|
|
dropdownBox.SetActive(!dropdownBox.activeSelf);
|
|
}
|
|
}
|