using SC.XR.Unity; using SC.XR.Unity.Module_InputSystem; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; public class BorderManager : SingletonMono { [HideInInspector] public bool isEnable=false;//是否开启此功能 const string boxName = "BoxSign"; Dictionary BoxSignDic; public void StartSearch() { isEnable = true; } public void StopSearch() { isEnable = false; } public void BtnClick() { if (!isEnable) { OpenFunc(); } else { CloseFunc(); } } public void OpenFunc() { //if (API_GSXR_Slam.SlamManager != null && !API_GSXR_Slam.GSXR_Is_SlamRunning()) //{ // return; //} StartSearch(); if (API_GSXR_Module_InputSystem.GSXR_InputDeviceStatus(InputDeviceType.GGT26Dof)) { InstantiateObj(API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTLeft); InstantiateObj(API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTRight); } else if (API_GSXR_Module_InputSystem.GSXR_InputDeviceStatus(InputDeviceType.KS)) { InstantiateObj(API_GSXR_Module_InputSystem_KS.GSXR_KSLeft); InstantiateObj(API_GSXR_Module_InputSystem_KS.GSXR_KSRight); } else if (API_GSXR_Module_InputSystem.GSXR_InputDeviceStatus(InputDeviceType.Head)) { InstantiateObj(API_GSXR_Module_InputSystem_Head.GSXR_Head); } } public void CloseFunc() { StopSearch(); foreach (var item in BoxSignDic.Values) { item.SetActive(false); } } void InstantiateObj(InputDevicePartBase part) { if (part.detectorBase.pointerBase.cursorBase.transform.GetComponentInChildren(true) == false) { GameObject obj = Instantiate(Resources.Load("Prefabs/BoundingBoxSign")); obj.transform.SetParent(part.detectorBase.pointerBase.cursorBase.transform); obj.transform.localPosition = Vector3.zero; obj.transform.localRotation = Quaternion.identity; obj.name = boxName + part.PartType; if (!BoxSignDic.ContainsKey(obj.name)) { BoxSignDic.Add(obj.name, obj); } } else { part.detectorBase.pointerBase.cursorBase.transform.GetComponentInChildren(true).gameObject.SetActive(true); } } #region MonoBehaviour Function private void Start() { BoxSignDic = new Dictionary(); } private void OnDestroy() { if (BoxSignDic!=null) { BoxSignDic.Clear(); } } #endregion }