StartXunJian.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. using Blue;
  2. using UnityEngine;
  3. using UnityEngine.Events;
  4. using UnityEngine.UI;
  5. namespace GHZLangChao
  6. {
  7. public class StartXunJian : AbstractController
  8. {
  9. public bool Test = false;
  10. [SerializeField] private RawImage ShowRawImage; // 显示的视频画面
  11. [SerializeField] private GameObject ShowRaw_go; // 显示的视频画面父物体
  12. [SerializeField] private Image[] arrayImage; // 截图显示的画面
  13. //[SerializeField] private Image ScreenshotImage; // 截图的画面
  14. private int arrayImageIndex = 0; // 截图显示时要显示在哪个Image上的下标
  15. [SerializeField] private Button[] ScreenshotBtnList;
  16. [SerializeField] private Button CancelBtn;
  17. [SerializeField] private Button SaveBtn;
  18. [SerializeField] private bool[] toggleBoolList;
  19. [SerializeField] private GameObject DefaultUI_go;
  20. [SerializeField] private GameObject EndUI_go;
  21. [SerializeField] private Button Titile_Btn;
  22. public UnityEvent OnReset = new UnityEvent();
  23. public UnityEvent OnRetract = new UnityEvent();
  24. public UnityEvent OnExpand = new UnityEvent();
  25. void Start()
  26. {
  27. foreach (Button btn in ScreenshotBtnList)
  28. {
  29. btn.onClick.AddListener(ClickScreenshot);
  30. }
  31. SaveBtn.onClick.AddListener(ClickSave);
  32. Titile_Btn.onClick.AddListener(ClickTitle);
  33. //CancelBtn.onClick.AddListener(ClickCancel);
  34. }
  35. private void Update()
  36. {
  37. if (Test) return;
  38. #if UNITY_EDITOR
  39. return;
  40. #endif
  41. OnReset?.Invoke();
  42. }
  43. public void Next()
  44. {
  45. ShowXunJian.Instance.gotoWindow(ScenesManager.SceneType.ShowDH);
  46. }
  47. public void back()
  48. {
  49. ScenesManager.Instance.showWindow(ScenesManager.SceneType.ShowChoose);
  50. }
  51. public void ShowDeviceInfo()
  52. {
  53. ScenesManager.Instance.showWindow(ScenesManager.SceneType.ShowDevice);
  54. }
  55. #region 按钮点击
  56. [SerializeField] private Sprite mScreenshotSprite;
  57. private void ClickScreenshot()
  58. {
  59. if (!ShowRaw_go.activeSelf)
  60. {
  61. ShowRaw_go.SetActive(true);
  62. XRRGBCamera.Instance.playCamera(1280, 720);
  63. ShowRawImage.texture = XRRGBCamera.Instance.CaptureImage;
  64. }
  65. }
  66. private void ClickSave()
  67. {
  68. var sprite = this.GetUtility<IRawImageForSpriteUtility>().SwitchSprite(ShowRawImage);
  69. //ScreenshotImage.gameObject.SetActive(true);
  70. //ScreenshotImage.sprite = sprite;
  71. arrayImage[arrayImageIndex].sprite = sprite;
  72. arrayImageIndex++;
  73. if (arrayImageIndex % 3 == 0)
  74. {
  75. arrayImageIndex -= 3;
  76. }
  77. }
  78. public void SetIndex(int index)
  79. {
  80. this.arrayImageIndex = index;
  81. }
  82. private void ClickCancel()
  83. {
  84. /*
  85. arrayImageIndex--;
  86. if (arrayImageIndex < 0)
  87. arrayImageIndex = arrayImage.Length - 1;
  88. arrayImage[arrayImageIndex].sprite = mScreenshotSprite;
  89. */
  90. }
  91. public void End()
  92. {
  93. foreach (bool isOn in toggleBoolList)
  94. {
  95. if (!isOn)
  96. {
  97. DefaultUI_go.SetActive(true);
  98. return;
  99. }
  100. }
  101. EndUI_go.SetActive(true);
  102. //ScenesManager.Instance.showWindow(ScenesManager.SceneType.ShowChoose);
  103. }
  104. public void SetToogleBool(int index)
  105. {
  106. toggleBoolList[index] = true;
  107. }
  108. private bool isRetract = false;
  109. private void ClickTitle()
  110. {
  111. isRetract = !isRetract;
  112. if(isRetract)
  113. OnRetract?.Invoke();
  114. else
  115. OnExpand?.Invoke();
  116. }
  117. #endregion
  118. }
  119. }