using Blue; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; namespace GHZLangChao { public class StartXunJian : AbstractController { public bool Test = false; [SerializeField] private RawImage ShowRawImage; // 显示的视频画面 [SerializeField] private GameObject ShowRaw_go; // 显示的视频画面父物体 [SerializeField] private Image[] arrayImage; // 截图显示的画面 //[SerializeField] private Image ScreenshotImage; // 截图的画面 private int arrayImageIndex = 0; // 截图显示时要显示在哪个Image上的下标 [SerializeField] private Button[] ScreenshotBtnList; [SerializeField] private Button CancelBtn; [SerializeField] private Button SaveBtn; [SerializeField] private bool[] toggleBoolList; [SerializeField] private GameObject DefaultUI_go; [SerializeField] private GameObject EndUI_go; [SerializeField] private Button Titile_Btn; public UnityEvent OnReset = new UnityEvent(); public UnityEvent OnRetract = new UnityEvent(); public UnityEvent OnExpand = new UnityEvent(); void Start() { foreach (Button btn in ScreenshotBtnList) { btn.onClick.AddListener(ClickScreenshot); } SaveBtn.onClick.AddListener(ClickSave); Titile_Btn.onClick.AddListener(ClickTitle); //CancelBtn.onClick.AddListener(ClickCancel); } private void Update() { if (Test) return; #if UNITY_EDITOR return; #endif OnReset?.Invoke(); } public void Next() { ShowXunJian.Instance.gotoWindow(ScenesManager.SceneType.ShowDH); } public void back() { ScenesManager.Instance.showWindow(ScenesManager.SceneType.ShowChoose); } public void ShowDeviceInfo() { ScenesManager.Instance.showWindow(ScenesManager.SceneType.ShowDevice); } #region 按钮点击 [SerializeField] private Sprite mScreenshotSprite; private void ClickScreenshot() { if (!ShowRaw_go.activeSelf) { ShowRaw_go.SetActive(true); XRRGBCamera.Instance.playCamera(1280, 720); ShowRawImage.texture = XRRGBCamera.Instance.CaptureImage; } } private void ClickSave() { var sprite = this.GetUtility().SwitchSprite(ShowRawImage); //ScreenshotImage.gameObject.SetActive(true); //ScreenshotImage.sprite = sprite; arrayImage[arrayImageIndex].sprite = sprite; arrayImageIndex++; if (arrayImageIndex % 3 == 0) { arrayImageIndex -= 3; } } public void SetIndex(int index) { this.arrayImageIndex = index; } private void ClickCancel() { /* arrayImageIndex--; if (arrayImageIndex < 0) arrayImageIndex = arrayImage.Length - 1; arrayImage[arrayImageIndex].sprite = mScreenshotSprite; */ } public void End() { foreach (bool isOn in toggleBoolList) { if (!isOn) { DefaultUI_go.SetActive(true); return; } } EndUI_go.SetActive(true); //ScenesManager.Instance.showWindow(ScenesManager.SceneType.ShowChoose); } public void SetToogleBool(int index) { toggleBoolList[index] = true; } private bool isRetract = false; private void ClickTitle() { isRetract = !isRetract; if(isRetract) OnRetract?.Invoke(); else OnExpand?.Invoke(); } #endregion } }