VuforiaFindAction.cs 3.2 KB

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