using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; using Platinio; namespace VRSDK { public enum Axis { Horizontal, Vertical, Forward } public enum VR_SDK { None, Oculus, Steam_VR, UnityXR } public class VR_Manager : Singleton { #region INSPECTOR [SerializeField] private VR_SDK currentSDK = VR_SDK.None; [SerializeField] private ControllerGestureConfig gestureConfig = null; #endregion #region PUBLIC public VR_SDK CurrentSDK { get { return currentSDK; } } public ControllerGestureConfig GestureConfig { get { return gestureConfig; } } public List InteractList { get { return interactList; } } public List HighlightList { get { return highlightList; } } public List GrabbableList { get { return grabbableList; } } public VR_Player Player { get { if (player == null) { player = FindFirstObjectByType(); player.Construct(); } return player; } } #endregion #region PRIVATE private List interactList = new List(); private List highlightList = new List(); private List grabbableList = new List(); private VR_Player player = null; #endregion protected override void Awake() { m_destroyOnLoad = false; base.Awake(); } public void SetCurrentPlayer(VR_Player player) { player.Construct(); } /// /// Register a grabbable object /// /// public void RegisterInteract(VR_Interactable interact) { if (interactList.Contains( interact )) return; interactList.Add( interact ); //is this is a grabbable to lets have it on a diferent list if (interact is VR_Grabbable) grabbableList.Add( interact as VR_Grabbable ); } /// /// Remove a grabbable object /// /// public void RemoveInteract(VR_Interactable interact) { interactList.Remove( interact ); //if this is a grabbable to remove it from grabbable list if (interact is VR_Grabbable) grabbableList.Remove( interact as VR_Grabbable ); } public void RegisterHighlight(VR_Highlight h) { highlightList.Add( h ); } public void RemoveHighlight(VR_Highlight h) { highlightList.Remove( h ); } public VR_Grabbable GetGrabbableFromCollider(Collider c) { for (int n = 0; n < interactList.Count; n++) { VR_Grabbable grabbable = interactList[n] as VR_Grabbable; if (grabbable != null && grabbable.ColliderList != null && grabbable.ColliderList.Count > 0 && grabbable.ColliderList.Contains( c )) { return grabbable; } } return null; } public void SetCurrentSDKViaEditor(VR_SDK sdk) { currentSDK = sdk; } } [System.Serializable] public class ControllerGestureConfig { public float minAcelerationThreshold = 15.0f; public float maxAcelerationThreshold = 40.0f; } }