-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainMenuManager.cs
More file actions
46 lines (39 loc) · 1.19 KB
/
MainMenuManager.cs
File metadata and controls
46 lines (39 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using UnityEngine;
using TMPro;
public class MainMenuManager : MonoBehaviour
{
[SerializeField] private TextMeshProUGUI usernameDisplay;
[SerializeField] private GameObject loginButton;
[SerializeField] private GameObject logoutButton;
private void Start()
{
// Load any saved session
SQLManager.LoadSavedSession();
// Update the UI
UpdateUserUI();
}
public void UpdateUserUI()
{
if (SQLManager.IsLoggedIn)
{
// Display the username
usernameDisplay.text = "Welcome, " + SQLManager.CurrentUsername + "!";
// Show logout button, hide login button
if (loginButton != null) loginButton.SetActive(false);
if (logoutButton != null) logoutButton.SetActive(true);
}
else
{
// No user is logged in
usernameDisplay.text = "Not logged in";
// Show login button, hide logout button
if (loginButton != null) loginButton.SetActive(true);
if (logoutButton != null) logoutButton.SetActive(false);
}
}
public void LogoutUser()
{
SQLManager.Logout();
UpdateUserUI();
}
}