123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- 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<BorderManager>
- {
- [HideInInspector]
- public bool isEnable=false;//是否开启此功能
- const string boxName = "BoxSign";
- Dictionary<string,GameObject> 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<BorderState>(true) == false)
- {
- GameObject obj = Instantiate(Resources.Load<GameObject>("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<BorderState>(true).gameObject.SetActive(true);
- }
- }
-
- #region MonoBehaviour Function
- private void Start()
- {
- BoxSignDic = new Dictionary<string, GameObject>();
- }
- private void OnDestroy()
- {
- if (BoxSignDic!=null)
- {
- BoxSignDic.Clear();
- }
-
-
- }
-
- #endregion
- }
|