123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482 |
- using BeinLab.Util;
- using DG.Tweening;
- using SC.XR.Unity.Module_InputSystem;
- using SC.XR.Unity.Module_InputSystem.InputDeviceHead;
- using SC.XR.Unity.Module_InputSystem.InputDeviceHand;
- using ShadowStudio.Tool;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using XRTool.Util;
- using XRTool.WorldUI;
- using ShadowStudio.Model;
- using SC.XR.Unity.Module_InputSystem.InputDeviceGC.BT3Dof;
- using SC.XR.Unity.Module_InputSystem.InputDeviceGC.KS;
- using Studio.Scripts;
- namespace ShadowStudio.UI
- {
- enum FilePanelType
- {
- ZiYuanKuDlg=0,
- PersonalDlg=1
- }
- [RequireComponent(typeof(WorldDlg))]
- /// <summary>
- /// 控制台窗口
- /// </summary>
- public class ConsoleDlg : UnitySingleton<ConsoleDlg>
- {
- private Transform AllMenuToggles;
- public List<GameObject> IconDlgList;
- public static int PaintBrushDlg = 0;
- public static int PiZhuDlg = 1;
- public static int ZiYuanKuDlg = 2;
- public static int PersonalFiledlg = 3;
- public static int FileListDlg = 4;
- private Transform IconDlgToggleGroupTran;
- private ToggleGroup IconDlgToggleGroup;
- public Toggle PiZhuToggle;
- private Button shortcutkey;
- public Transform AnmationPos;
- private Button userInfoBt;
- //private Button WenJianBt;
- private WorldDlg fileListDlg;
- public Camera vufora_camera;
- public Transform NotePadPar;
- public Transform WorldCanvas;
- public GameObject TipPop;
- public Text TipPopText;
- public static bool IsOne = false;
- public Vector3 GetCenterPos()
- {
- if (shortcutkey)
- {
- return shortcutkey.transform.position;
- }
- return Vector3.zero;
- }
- private void Start()
- {
- ArtInfoMgr.Instance.InitPackage(HomeProxy.Instance.ArtList);
- WorldDlg dlg = GetComponent<WorldDlg>();
- AnmationPos = dlg.GetBreadthChild<Transform>("AnmationPos");
- fileListDlg = dlg.GetBreadthChild<WorldDlg>("FileListDlg");
- fileListDlg.gameObject.SetActive(false);
- AllMenuToggles = dlg.GetBreadthChild<Transform>("AllMenuToggles");
- IconDlgToggleGroup = dlg.GetBreadthChild<ToggleGroup>("IconDlgToggleGroup");
- IconDlgToggleGroupTran = dlg.GetBreadthChild<Transform>("IconDlgToggleGroup");
- userInfoBt = dlg.GetBreadthChild<Button>("userInfoBt");
- shortcutkey = dlg.GetBreadthChild<Button>("Shortcutkey");
- // scanPictureBtn = dlg.GetBreadthChild<Button>("ScanPictureBtn");
- shortcutkey.onClick.AddListener(ClickOnShortcutkey);
- //scanPictureBtn.onClick.AddListener(ClickOnScan);
- for (int i = 0; i < IconDlgToggleGroupTran.childCount; i++)
- {
- Toggle toggle = IconDlgToggleGroupTran.GetChild(i).GetComponent<Toggle>();
- toggle.onValueChanged.AddListener((bool isOn) => { OnToggle(isOn, toggle); });
- if (i == 1)
- {
- PiZhuToggle = toggle;
- }
- }
- if (GameSession.Instance)
- {
- GameSession.Instance.CameraEffect(true);
- }
- shortcutkey.gameObject.SetActive(false);
- InitScan();
- //Debug.Log(CommonMethod.roomConfig.Type + "***" + CommonMethod.roomConfig.Room_type + "+++" + CommonMethod.roomConfig.Is_created);
- if (CommonMethod.roomConfig.Type == "2")
- {
- if (CommonMethod.roomConfig.Room_type == "2")
- {
- Invoke("shortcutkeyShow", 1f);
- }
- else
- {
- if (CommonMethod.roomConfig.Is_created == "1")
- {
- Invoke("shortcutkeyShow", 1f);
- }
- }
- }
- else
- {
- Invoke("shortcutkeyShow", 1f);
- }
- //TimerMgr.Instance.CreateTimer(() =>
- //{
- // if (TransferCell.curActiveCell && !TransferCell.curActiveCell.IsLock)
- // {
- // TransferCell.curActiveCell.DisActiveCell();
- // }
- //}, 1.2f);
- }
- private void InitScan()
- {
- vufora_camera.enabled = false;
- Vuforia.VuforiaBehaviour.Instance.enabled = false;
- }
- public void ClickOnScan()
- {
- if (vufora_camera.enabled == true)
- {
- CommonMethod.ShowScanEffect(false);
- vufora_camera.enabled = false;
- Vuforia.VuforiaBehaviour.Instance.enabled = false;
- //if (StudioRtc.Instance != null && StudioRtc.Instance.me != null)
- //{
- // // StudioRtc.Instance.startCamera();
- //}
- if (ScanPictureBtn.Instance.Bg)
- {
- ScanPictureBtn.Instance.Bg.gameObject.SetActive(false);
- }
- //AgoraVideoAudioManager.Instance.OnClickEnableLocalVideo(true);
-
- //if (StudioRtc.Instance != null && StudioRtc.Instance.me != null)
- //{
- // StudioRtc.Instance.stopCamera();
- //}
-
- AgoraRTCManager.Instance.JoinChannel();
- }
- else
- {
- if(AgoraRTCManager.Instance.isSwitchCamera)
- {
- AgoraRTCManager.Instance.RtcEngine.SwitchCamera();
- AgoraRTCManager.Instance.isSwitchCamera = !AgoraRTCManager.Instance.isSwitchCamera;
- }
- AgoraRTCManager.Instance.LeaveChannel();
- // AgoraVideoAudioManager.Instance.OnClickEnableLocalVideo(false);
- //if (StudioRtc.Instance != null && StudioRtc.Instance.me != null)
- //{
- // StudioRtc.Instance.stopCamera();
- //}
- CommonMethod.ShowScanEffect(true);
- vufora_camera.enabled = true;
- Vuforia.VuforiaBehaviour.Instance.enabled = true;
- if (ScanPictureBtn.Instance.Bg)
- {
- ScanPictureBtn.Instance.Bg.gameObject.SetActive(true);
- }
- }
- }
- public void CloseScan()
- {
- //if (vufora_camera.enabled == true)
- //{
- // CommonMethod.ShowScanEffect(false);
- // vufora_camera.enabled = false;
- // Vuforia.VuforiaBehaviour.Instance.enabled = false;
- // //if (StudioRtc.Instance != null && StudioRtc.Instance.me != null)
- // //{
- // // StudioRtc.Instance.startCamera();
- // //}
- //}
- }
- private void shortcutkeyShow()
- {
- shortcutkey.gameObject.SetActive(true);
- }
- private void ClickOnShortcutkey()
- {
- if (isHide)
- {
- shortcutkey.GetComponent<ButtonEffect>().enabled = false;
- isHide = false;
- GameEffect.setAlpha(shortcutkey.gameObject, 0, 0.25f, (GameObject obj) =>
- {
- shortcutkey.gameObject.SetActive(false);
- });
- GameEffect.setAlpha(AllMenuToggles.gameObject, 1, 0.01f, (GameObject obj) =>
- {
- });
- AllMenuToggles.gameObject.SetActive(true);
- ListButtonEffect[] list = AllMenuToggles.GetComponentsInChildren<ListButtonEffect>();
- for (int i = 0; i < list.Length; i++)
- {
- list[i].showMove();
- }
- if (GameSession.Instance)
- {
- GameSession.Instance.CameraEffect(false);
- }
- }
- }
- private void OnToggle(bool isOn, Toggle toggle)
- {
- if (isOn)
- {
- switch (toggle.name)
- {
- case "PaintBrush":
- ShowIconDlgs(PaintBrushDlg);
- DrawPener.Instance.ActiveDrawPen();
- DesAllNotepad();
- break;
- case "NotePad":
- ShowIconDlgs(PiZhuDlg);
- DrawPener.Instance.DisActiveDrawPen();
- ArtContainer container = NotePadComponent.CreateLocalNotePad();
- TimerMgr.Instance.CreateTimer(() => { InitNotePad(container); }, 0f);
- break;
- case "ZiYuanKu":
- ShowIconDlgs(ZiYuanKuDlg);
- DrawPener.Instance.DisActiveDrawPen();
- DesAllNotepad();
- break;
- case "PersonalFile":
- ShowIconDlgs(PersonalFiledlg);
- DrawPener.Instance.DisActiveDrawPen();
- DesAllNotepad();
- break;
- case "SenceMgr":
- ShowIconDlgs(FileListDlg);
- DrawPener.Instance.DisActiveDrawPen();
- DesAllNotepad();
- break;
- }
- }
- else
- {
- if (!IconDlgToggleGroup.AnyTogglesOn())
- {
- CloseAllDlgs();
- DesAllNotepad();
- DrawPener.Instance.DisActiveDrawPen();
- }
- }
- }
- public void SetClose()
- {
- IconDlgToggleGroup.SetAllTogglesOff();
- }
- private void DesAllNotepad()
- {
- if (NotePadPar && NotePadPar.childCount > 0)
- {
- for (int i = 0; i < NotePadPar.childCount; i++)
- {
- Destroy(NotePadPar.GetChild(i).gameObject);
- }
- }
- }
- private void InitNotePad(ArtContainer container)
- {
- Transform NotePadTran = container.GetInstace().transform;
- NotePadTran.SetParent(NotePadPar, true);
- NotePadTran.localPosition = new Vector3(0f, 0f, 0f);
- NotePadTran.localEulerAngles = new Vector3(0f, 0f, 0f);
- NotePadTran.localScale = new Vector3(1250f, 1250f, 1250f);
- //NotePadTran.position = NotePadPar.position;
- //NotePadTran.rotation = NotePadPar.rotation;
- NotePadComponent notePadComponent = NotePadTran.GetComponentInChildren<NotePadComponent>();
- notePadComponent.Init();
- }
- private void Update()
- {
- checkMenu();
- }
- private bool isHide = true;
- private float TimeData;
- private List<GameObject> raycastList;
- public void checkMenu()
- {
- if (!IconDlgToggleGroup.AnyTogglesOn() && !isHide)
- {
- List<GameObject> list = checkFoucs();
- bool isLock = false;
- for (int i = 0; i < list.Count; i++)
- {
- if (list[i] != null)
- {
- isLock = true;
- break;
- }
- }
- if (!isLock)
- {
- TimeData = TimeData + Time.deltaTime;
- if (TimeData >= 2f)
- {
- TimeData = 0;
- HeidMenu();
- }
- }
- else
- {
- TimeData = 0;
- }
- }
- else
- {
- TimeData = 0;
- }
- }
- private void OnEnable()
- {
- DispatcherBase.KeyDownDelegateRegister(OnKeyDownAction);
- }
- private void OnKeyDownAction(InputKeyCode keyCode, InputDevicePartBase part)
- {
- var obj = part.inputDataBase.SCPointEventData.pointerCurrentRaycast.gameObject;//SDK里判断点击返回的物体
- if (!obj && !IconDlgToggleGroup.AnyTogglesOn() && !isHide)
- {
- HeidMenu();
- }
- if (!obj)
- {
- TransferCell.CancelCell();
- }
- }
- private void OnDisable()
- {
- TransferCell.CancelCell();
- DispatcherBase.KeyDownDelegateUnRegister(OnKeyDownAction);
- }
- public List<GameObject> checkFoucs()
- {
- if (raycastList == null)
- {
- raycastList = new List<GameObject>();
- }
- raycastList.Clear();
- InputDeviceBase inputdevice;
- inputdevice = Module_InputSystem.instance.GetInputDevice<InputDeviceHead>(InputDeviceType.Head);
- checkFoucs(raycastList, inputdevice);
- inputdevice = Module_InputSystem.instance.GetInputDevice<InputDeviceHand>(InputDeviceType.GGT26Dof);
- checkFoucs(raycastList, inputdevice);
- inputdevice = Module_InputSystem.instance.GetInputDevice<InputDeviceHand>(InputDeviceType.GGT26Dof);
- checkFoucs(raycastList, inputdevice);
- inputdevice = Module_InputSystem.instance.GetInputDevice<InputDeviceBT3Dof>(InputDeviceType.BT3Dof);
- checkFoucs(raycastList, inputdevice);
- inputdevice = Module_InputSystem.instance.GetInputDevice<InputDeviceKS>(InputDeviceType.KS);
- checkFoucs(raycastList, inputdevice);
- return raycastList;
- }
- private void checkFoucs(List<GameObject> raycastList, InputDeviceBase inputdevice)
- {
- if (inputdevice && inputdevice.inputDevicePartList != null)
- {
- foreach (var part in inputdevice.inputDevicePartList)
- {
- if (part && part.inputDataBase != null && part.inputDataBase.isVaild)
- {
- raycastList.Add(part.inputDataBase.SCPointEventData.pointerCurrentRaycast.gameObject);
- }
- }
- }
- }
- public void HeidMenu()
- {
- shortcutkey.GetComponent<ButtonEffect>().enabled = true;
- isHide = true;
- GameEffect.setAlpha(AllMenuToggles.gameObject, 0, 0.25F, (GameObject obj) => { obj.SetActive(false); });
- GameEffect.setAlpha(shortcutkey.gameObject, 1, 0.25F, (GameObject obj) => { obj.SetActive(true); });
- ListEffect[] listeffects = AllMenuToggles.GetComponentsInChildren<ListEffect>();
- for (int i = 0; i < listeffects.Length; i++)
- {
- listeffects[i].hideEffect();
- }
- ListButtonEffect[] list = AllMenuToggles.GetComponentsInChildren<ListButtonEffect>();
- for (int i = 0; i < list.Length; i++)
- {
- list[i].hideMove();
- }
- //aboutMeDlg.hideDlg();
- //fileListDlg.hideDlg();
- if (GameSession.Instance)
- {
- GameSession.Instance.CameraEffect(true);
- }
- }
- public void CloseAllDlgs()
- {
- for (int i = 0; i < IconDlgList.Count; i++)
- {
- if (IconDlgList[i].activeSelf)
- {
- IconDlgList[i].SetActive(false);
- //GameEffect.setAlpha(IconDlgList[i].gameObject, 0, 0.25f, (GameObject obj) =>
- //{
- // obj.SetActive(false);
- //});
- }
- }
- }
- public void xiao()
- {
- // OpenXRCamera.Instance.leftCamera.transform.localPosition = new Vector3(OpenXRCamera.Instance.head.GetComponent<Camera>().transform.localPosition.x - 0.001f, OpenXRCamera.Instance.head.GetComponent<Camera>().transform.localPosition.y, OpenXRCamera.Instance.leftCamera.transform.localPosition.z);
- // OpenXRCamera.Instance.rightCamera.transform.localPosition = new Vector3(OpenXRCamera.Instance.head.GetComponent<Camera>().transform.localPosition.x + 0.001f, OpenXRCamera.Instance.head.GetComponent<Camera>().transform.localPosition.y, OpenXRCamera.Instance.rightCamera.transform.localPosition.z);
- }
- public void da()
- {
- // OpenXRCamera.Instance.leftCamera.transform.localPosition = new Vector3(OpenXRCamera.Instance.head.GetComponent<Camera>().transform.localPosition.x + 0.001f, OpenXRCamera.Instance.head.GetComponent<Camera>().transform.localPosition.y, OpenXRCamera.Instance.leftCamera.transform.localPosition.z);
- // OpenXRCamera.Instance.rightCamera.transform.localPosition = new Vector3(OpenXRCamera.Instance.head.GetComponent<Camera>().transform.localPosition.x - 0.001f, OpenXRCamera.Instance.head.GetComponent<Camera>().transform.localPosition.y, OpenXRCamera.Instance.rightCamera.transform.localPosition.z);
- }
- public void ShowIconDlgs(int index)
- {
- for (int i = 0; i < IconDlgList.Count; i++)
- {
- if (index == i)
- {
- IconDlgList[i].SetActive(true);
- }
- else
- {
-
- if (IconDlgList[i].activeSelf)
- {
- IconDlgList[i].gameObject.SetActive(false);
- }
- }
- }
- }
- public void ShowTipPop(string msg)
- {
- TipPop.SetActive(true);
- TipPopText.text = msg;
- Invoke("HideTipPop", 3f);
- }
- private void HideTipPop()
- {
- TipPop.SetActive(false);
- }
- }
- }
|