LoginUI.cs 782 B

1234567891011121314151617181920212223242526272829
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. namespace Mirror.Examples.Chat
  4. {
  5. public class LoginUI : MonoBehaviour
  6. {
  7. [Header("UI Elements")]
  8. [SerializeField] internal InputField usernameInput;
  9. [SerializeField] internal Button hostButton;
  10. [SerializeField] internal Button clientButton;
  11. [SerializeField] internal Text errorText;
  12. public static LoginUI instance;
  13. void Awake()
  14. {
  15. instance = this;
  16. }
  17. // Called by UI element UsernameInput.OnValueChanged
  18. public void ToggleButtons(string username)
  19. {
  20. hostButton.interactable = !string.IsNullOrWhiteSpace(username);
  21. clientButton.interactable = !string.IsNullOrWhiteSpace(username);
  22. }
  23. }
  24. }