Spaces:
Sleeping
Sleeping
Download project/Assets/Scripts/UI/DinoAdminUI.cs from alfarouqwebserver/SWS-Smarta: direct link, hf CLI and curl.
- Browser
- Download file 1.68 kB
-
https://huggingface.co/spaces/alfarouqwebserver/SWS-Smarta/resolve/main/project/Assets/Scripts/UI/DinoAdminUI.cs
- Command line
-
hf download hf://spaces/alfarouqwebserver/SWS-Smarta/project/Assets/Scripts/UI/DinoAdminUI.cs
-
curl -L -o DinoAdminUI.cs https://huggingface.co/spaces/alfarouqwebserver/SWS-Smarta/resolve/main/project/Assets/Scripts/UI/DinoAdminUI.cs
1.68 kB
| using TMPro; | |
| using UnityEngine; | |
| using UnityEngine.UI; | |
| public class DinoAdminUI : MonoBehaviour | |
| { | |
| public DinoAdminAccess adminAccess; | |
| public TMP_InputField adminCodeInput; | |
| public InputField adminCodeInputLegacy; | |
| public TMP_Text statusText; | |
| public Text statusTextLegacy; | |
| public Button loginButton; | |
| public Button logoutButton; | |
| public string okMessage = "Admin mode enabled"; | |
| public string failMessage = "Invalid admin code"; | |
| void Start() | |
| { | |
| if (loginButton != null) | |
| loginButton.onClick.AddListener(OnLogin); | |
| if (logoutButton != null) | |
| logoutButton.onClick.AddListener(OnLogout); | |
| } | |
| void OnLogin() | |
| { | |
| if (adminAccess == null) | |
| adminAccess = DinoAdminAccess.Instance; | |
| string code = ReadInput(adminCodeInput, adminCodeInputLegacy, ""); | |
| bool ok = adminAccess != null && adminAccess.TryLogin(code); | |
| SetText(ok ? okMessage : failMessage); | |
| } | |
| void OnLogout() | |
| { | |
| if (adminAccess == null) | |
| adminAccess = DinoAdminAccess.Instance; | |
| if (adminAccess != null) | |
| adminAccess.Logout(); | |
| SetText("Admin mode off"); | |
| } | |
| string ReadInput(TMP_InputField tmp, InputField legacy, string fallback) | |
| { | |
| if (tmp != null && !string.IsNullOrWhiteSpace(tmp.text)) | |
| return tmp.text; | |
| if (legacy != null && !string.IsNullOrWhiteSpace(legacy.text)) | |
| return legacy.text; | |
| return fallback; | |
| } | |
| void SetText(string value) | |
| { | |
| if (statusText != null) statusText.text = value; | |
| if (statusTextLegacy != null) statusTextLegacy.text = value; | |
| } | |
| } | |