ErrorDialog.cs 849 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System;
  2. using UnityEngine;
  3. using UnityEngine.Events;
  4. using UnityEngine.UI;
  5. namespace TriLib.Samples
  6. {
  7. public class ErrorDialog : MonoBehaviour
  8. {
  9. public static ErrorDialog Instance { get; private set; }
  10. public string Text
  11. {
  12. get
  13. {
  14. return this._errorText.text;
  15. }
  16. set
  17. {
  18. this._errorText.text = value;
  19. }
  20. }
  21. protected void Awake()
  22. {
  23. this._okButton.onClick.AddListener(new UnityAction(this.HideDialog));
  24. ErrorDialog.Instance = this;
  25. }
  26. public void ShowDialog(string text)
  27. {
  28. this.Text = text;
  29. this._rendererGameObject.SetActive(true);
  30. }
  31. public void HideDialog()
  32. {
  33. this._rendererGameObject.SetActive(false);
  34. }
  35. [SerializeField]
  36. private Button _okButton;
  37. [SerializeField]
  38. private InputField _errorText;
  39. [SerializeField]
  40. private GameObject _rendererGameObject;
  41. }
  42. }