StartXunJian.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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 = true;
  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 UNITY_EDITOR
  38. if (Test) return;
  39. #endif
  40. OnReset?.Invoke();
  41. }
  42. public void Next()
  43. {
  44. ShowXunJian.Instance.gotoWindow(ScenesManager.SceneType.ShowDH);
  45. }
  46. public void back()
  47. {
  48. ScenesManager.Instance.showWindow(ScenesManager.SceneType.ShowChoose);
  49. }
  50. public void ShowDeviceInfo()
  51. {
  52. ScenesManager.Instance.showWindow(ScenesManager.SceneType.ShowDevice);
  53. }
  54. #region 按钮点击
  55. [SerializeField] private Sprite mScreenshotSprite;
  56. private void ClickScreenshot()
  57. {
  58. if (!ShowRaw_go.activeSelf)
  59. {
  60. ShowRaw_go.SetActive(true);
  61. XRRGBCamera.Instance.playCamera(1280, 720);
  62. ShowRawImage.texture = XRRGBCamera.Instance.CaptureImage;
  63. }
  64. }
  65. private void ClickSave()
  66. {
  67. var sprite = this.GetUtility<IRawImageForSpriteUtility>().SwitchSprite(ShowRawImage);
  68. //ScreenshotImage.gameObject.SetActive(true);
  69. //ScreenshotImage.sprite = sprite;
  70. arrayImage[arrayImageIndex].sprite = sprite;
  71. arrayImageIndex++;
  72. if (arrayImageIndex % 3 == 0)
  73. {
  74. arrayImageIndex -= 3;
  75. }
  76. }
  77. public void SetIndex(int index)
  78. {
  79. this.arrayImageIndex = index;
  80. }
  81. private void ClickCancel()
  82. {
  83. /*
  84. arrayImageIndex--;
  85. if (arrayImageIndex < 0)
  86. arrayImageIndex = arrayImage.Length - 1;
  87. arrayImage[arrayImageIndex].sprite = mScreenshotSprite;
  88. */
  89. }
  90. public void End()
  91. {
  92. foreach (bool isOn in toggleBoolList)
  93. {
  94. if (!isOn)
  95. {
  96. DefaultUI_go.SetActive(true);
  97. return;
  98. }
  99. }
  100. EndUI_go.SetActive(true);
  101. //ScenesManager.Instance.showWindow(ScenesManager.SceneType.ShowChoose);
  102. }
  103. public void SetToogleBool(int index)
  104. {
  105. toggleBoolList[index] = true;
  106. }
  107. private bool isRetract = false;
  108. private void ClickTitle()
  109. {
  110. isRetract = !isRetract;
  111. if(isRetract)
  112. OnRetract?.Invoke();
  113. else
  114. OnExpand?.Invoke();
  115. }
  116. #endregion
  117. }
  118. }