NRGlassesInitErrorTip.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /****************************************************************************
  2. * Copyright 2019 Nreal Techonology Limited. All rights reserved.
  3. *
  4. * This file is part of NRSDK.
  5. *
  6. * https://www.nreal.ai/
  7. *
  8. *****************************************************************************/
  9. namespace NRKernal
  10. {
  11. using System;
  12. using UnityEngine;
  13. using UnityEngine.UI;
  14. /// <summary> A nr glasses initialize error tip. </summary>
  15. public class NRGlassesInitErrorTip : MonoBehaviour
  16. {
  17. /// <summary> Event queue for all listeners interested in OnPreComfirm events. </summary>
  18. public static event Action OnPreComfirm;
  19. /// <summary> Event queue for all listeners interested in OnConfirm events. </summary>
  20. public event Action OnConfirm;
  21. /// <summary> The confirm control. </summary>
  22. public Button m_ConfirmBtn;
  23. /// <summary> The tips. </summary>
  24. public Text m_Tips;
  25. /// <summary> Initializes this object. </summary>
  26. /// <param name="msg"> The message.</param>
  27. /// <param name="confirm"> The confirm.</param>
  28. public virtual void Init(string msg, Action confirm)
  29. {
  30. m_Tips.text = msg;
  31. OnConfirm += confirm;
  32. m_ConfirmBtn.onClick.AddListener(() =>
  33. {
  34. OnConfirm?.Invoke();
  35. });
  36. Invoke("AutoConfirm", 5f);
  37. }
  38. /// <summary> Starts this object. </summary>
  39. private void Start()
  40. {
  41. var inputmodule = GameObject.FindObjectOfType<NRInputModule>();
  42. if (inputmodule != null)
  43. {
  44. GameObject.Destroy(inputmodule.gameObject);
  45. }
  46. OnPreComfirm?.Invoke();
  47. }
  48. /// <summary> Automatic confirm. </summary>
  49. private void AutoConfirm()
  50. {
  51. OnConfirm?.Invoke();
  52. }
  53. }
  54. }