DFCheckBehaviour.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using UnityEngine;
  2. using Rokid.UXR.Native;
  3. using Rokid.UXR.UI;
  4. using UnityEngine.SceneManagement;
  5. namespace Rokid.UXR.Module
  6. {
  7. /// <summary>
  8. /// Device diagnostic tool
  9. /// </summary>
  10. public class DFCheckBehaviour : MonoBehaviour
  11. {
  12. public float delayTime = 5;
  13. private bool checkValid;
  14. public FuncDeviceCheck.FuncEnum needCheckFunc;
  15. void Start()
  16. {
  17. #if !UNITY_EDITOR
  18. if (!CheckDevice())
  19. {
  20. //add tip
  21. string tipInfo = string.Format("当前设备{0},不支持{1}功能,{2}秒后退出场景", NativeInterface.NativeAPI.GetGlassName(), needCheckFunc.ToString(), delayTime);
  22. UIManager.Instance().CreatePanel<TipPanel>(true).Init(tipInfo, TipLevel.Error, delayTime, () =>
  23. {
  24. if (SceneManager.GetActiveScene().buildIndex == 0)
  25. {
  26. Quit();
  27. }
  28. else
  29. {
  30. SceneManager.LoadScene(0);
  31. }
  32. });
  33. }
  34. #endif
  35. }
  36. public void Quit()
  37. {
  38. Application.Quit();
  39. NativeInterface.NativeAPI.KillProcess();
  40. }
  41. public bool CheckDevice()
  42. {
  43. return FuncDeviceCheck.CheckFunc(needCheckFunc);
  44. }
  45. }
  46. }