VuforiaFindAction.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. using ShadowStudio.Tool;
  2. using ShadowStudio.UI;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using UnityEngine;
  6. using Vuforia;
  7. using XRTool.Util;
  8. public class VuforiaFindAction : DefaultObserverEventHandler// DefaultTrackableEventHandler
  9. {
  10. private bool isFind;
  11. private bool isOk = true;
  12. protected override void OnTrackingFound()
  13. {
  14. isFind = true;
  15. }
  16. protected override void OnTrackingLost()
  17. {
  18. isFind = false;
  19. }
  20. private float times;
  21. // Update is called once per frame
  22. void Update()
  23. {
  24. if (isFind)
  25. {
  26. times = times + Time.deltaTime;
  27. if (times <= 0.5)
  28. {
  29. isOk = false;
  30. }
  31. else
  32. {
  33. BoardDlg.Instance.transform.position = this.transform.position + new Vector3(0f, 1.5f, 0f) + this.transform.forward.normalized * 2;
  34. BoardDlg.Instance.transform.eulerAngles = new Vector3(0, this.transform.eulerAngles.y, 0);//重点
  35. BoardDlg.Instance.OnDragTransfer();
  36. if (!CheckDeviceType.checkIsPhone())
  37. {
  38. if (ConsoleDlg.Instance && ConsoleDlg.Instance.vufora_camera)
  39. {
  40. if (DeviceType.type == "Phone")
  41. {
  42. }
  43. else
  44. {
  45. ConsoleDlg.Instance.vufora_camera.enabled = false;
  46. }
  47. }
  48. if (VuforiaBehaviour.Instance)
  49. {
  50. if (DeviceType.type == "Phone")
  51. {
  52. }else
  53. {
  54. VuforiaBehaviour.Instance.enabled = false;
  55. }
  56. }
  57. }
  58. CommonMethod.ShowScanEffect(false);
  59. if (ScanPictureBtn.Instance.Bg)
  60. {
  61. ScanPictureBtn.Instance.Bg.gameObject.SetActive(false);
  62. }
  63. isFind = false;
  64. isOk = true;
  65. //if (StudioRtc.Instance != null && StudioRtc.Instance.me.cIdV != "")
  66. //{
  67. // StudioRtc.Instance.startCamera();
  68. //}
  69. XRRGBCamera.Instance.playCamera();
  70. AgoraRTCManager.Instance.JoinChannel();
  71. }
  72. }
  73. else
  74. {
  75. RefClilk();
  76. }
  77. }
  78. public void RefClilk()
  79. {
  80. times = 0;
  81. if (!isOk)
  82. {
  83. if (!CheckDeviceType.checkIsPhone())
  84. {
  85. if (ConsoleDlg.Instance && ConsoleDlg.Instance.vufora_camera)
  86. {
  87. if (DeviceType.type == "Phone")
  88. {
  89. }
  90. else
  91. {
  92. ConsoleDlg.Instance.vufora_camera.enabled = false;
  93. }
  94. }
  95. }
  96. if (VuforiaBehaviour.Instance)
  97. {
  98. if (DeviceType.type == "Phone")
  99. {
  100. }
  101. else
  102. {
  103. VuforiaBehaviour.Instance.enabled = false;
  104. }
  105. }
  106. //if (StudioRtc.Instance != null && StudioRtc.Instance.me != null && StudioRtc.Instance.me.cIdV != "")
  107. //{
  108. // StudioRtc.Instance.startCamera();
  109. //}
  110. XRRGBCamera.Instance.playCamera();
  111. CommonMethod.ShowScanEffect(false);
  112. if (ScanPictureBtn.Instance.Bg)
  113. {
  114. ScanPictureBtn.Instance.Bg.gameObject.SetActive(false);
  115. }
  116. isOk = true;
  117. }
  118. }
  119. }