/// <summary> /// The GetBoundariesSDK method returns the selected boundaries SDK /// </summary> /// <returns>The currently selected Boundaries SDK</returns> public SDK_BaseBoundaries GetBoundariesSDK() { SDK_BaseBoundaries returnSDK = null; switch (boundariesSDK) { case SupportedSDKs.SteamVR: returnSDK = ScriptableObject.CreateInstance <SDK_SteamVRBoundaries>(); break; case SupportedSDKs.OculusVR: returnSDK = ScriptableObject.CreateInstance <SDK_OculusVRBoundaries>(); break; case SupportedSDKs.Simulator: returnSDK = ScriptableObject.CreateInstance <SDK_SimBoundaries>(); break; default: Debug.LogError("No valid Boundaries SDK has been selected. If you're seeing this error in Unity Edit mode, then try selecting the GameObject with the `VRTK_SDKManager` script and selecting a valid Boundaries SDK from the dropdown list."); returnSDK = ScriptableObject.CreateInstance <SDK_FallbackBoundaries>(); break; } return(returnSDK); }
/// <summary> /// Populates the object references by using the currently set SDKs. /// </summary> /// <param name="force">Whether to ignore <see cref="autoPopulateObjectReferences"/> while deciding to populate.</param> public void PopulateObjectReferences(bool force) { if (!(force || autoPopulateObjectReferences) || automaticSDKSelection) { return; } actualBoundaries = null; actualHeadset = null; actualLeftController = null; actualRightController = null; modelAliasLeftController = null; modelAliasRightController = null; SDK_BaseBoundaries boundariesSDK = GetBoundariesSDK(); SDK_BaseHeadset headsetSDK = GetHeadsetSDK(); SDK_BaseController controllerSDK = GetControllerSDK(); Transform playAreaTransform = boundariesSDK.GetPlayArea(); Transform headsetTransform = headsetSDK.GetHeadset(); actualBoundaries = playAreaTransform == null ? null : playAreaTransform.gameObject; actualHeadset = headsetTransform == null ? null : headsetTransform.gameObject; actualLeftController = controllerSDK.GetControllerLeftHand(true); actualRightController = controllerSDK.GetControllerRightHand(true); modelAliasLeftController = controllerSDK.GetControllerModel(SDK_BaseController.ControllerHand.Left); modelAliasRightController = controllerSDK.GetControllerModel(SDK_BaseController.ControllerHand.Right); }
public static void InvalidateCaches() { #if UNITY_EDITOR Object.DestroyImmediate(systemSDK); Object.DestroyImmediate(headsetSDK); Object.DestroyImmediate(controllerSDK); Object.DestroyImmediate(boundariesSDK); Object.DestroyImmediate(trackerSDK); Object.DestroyImmediate(handSDK); #else Object.Destroy(systemSDK); Object.Destroy(headsetSDK); Object.Destroy(controllerSDK); Object.Destroy(boundariesSDK); Object.Destroy(trackerSDK); Object.Destroy(handSDK); #endif systemSDK = null; headsetSDK = null; controllerSDK = null; boundariesSDK = null; trackerSDK = null; handSDK = null; }
private static SDK_BaseBoundaries GetBoundariesSDK() { if (boundariesSDK == null) { boundariesSDK = (VRTK_SDKManager.instance ? VRTK_SDKManager.instance.GetBoundariesSDK() : ScriptableObject.CreateInstance <SDK_FallbackBoundaries>()); } return(boundariesSDK); }
/// <summary> /// The GetBoundariesSDK method returns the selected boundaries SDK. /// </summary> /// <returns>The currently selected boundaries SDK.</returns> public SDK_BaseBoundaries GetBoundariesSDK() { if (cachedBoundariesSDK == null) { HandleSDKGetter <SDK_BaseBoundaries>("Boundaries", boundariesSDKInfo, InstalledBoundariesSDKInfos); cachedBoundariesSDK = (SDK_BaseBoundaries)ScriptableObject.CreateInstance(boundariesSDKInfo.type); } return(cachedBoundariesSDK); }
public static SDK_BaseBoundaries GetBoundariesSDK() { if (VRTK_SDKManager.instance != null && VRTK_SDKManager.instance.loadedSetup != null) { return(VRTK_SDKManager.instance.loadedSetup.boundariesSDK); } if (boundariesSDK == null) { boundariesSDK = ScriptableObject.CreateInstance <SDK_FallbackBoundaries>(); } return(boundariesSDK); }
/// <summary> /// The GetBoundariesSDK method returns the selected boundaries SDK /// </summary> /// <returns>The currently selected Boundaries SDK</returns> public SDK_BaseBoundaries GetBoundariesSDK() { SDK_BaseBoundaries returnSDK = null; switch (boundariesSDK) { case SupportedSDKs.SteamVR: returnSDK = ScriptableObject.CreateInstance <SDK_SteamVRBoundaries>(); break; case SupportedSDKs.OculusVR: returnSDK = ScriptableObject.CreateInstance <SDK_OculusVRBoundaries>(); break; default: returnSDK = ScriptableObject.CreateInstance <SDK_FallbackBoundaries>(); break; } return(returnSDK); }
private static SDK_InterfaceBoundaries GetBoundariesSDK() { if (boundariesSDK == null) { boundariesSDK = ScriptableObject.CreateInstance <SDK_FallbackBoundaries>(); if (VRTK_SDKManager.instance) { switch (VRTK_SDKManager.instance.boundariesSDK) { case VRTK_SDKManager.SupportedSDKs.SteamVR: boundariesSDK = ScriptableObject.CreateInstance <SDK_SteamVRBoundaries>(); break; default: Debug.LogError("No Boundaries SDK configured, falling back to generic Boundaries SDK."); break; } } } return(boundariesSDK); }
private void AutoPopulate(VRTK_SDKManager sdkManager) { var boundariesSDK = GetBoundariesSDK(sdkManager); var headsetSDK = GetHeadsetSDK(sdkManager); var controllerSDK = GetControllerSDK(sdkManager); var forceSaveScene = false; if (boundariesSDK && (!sdkManager.actualBoundaries || !previousBoundariesSDK || boundariesSDK.GetType() != previousBoundariesSDK.GetType())) { var playareaTransform = boundariesSDK.GetPlayArea(); sdkManager.actualBoundaries = (playareaTransform ? playareaTransform.gameObject : null); previousBoundariesSDK = boundariesSDK; forceSaveScene = true; } if (headsetSDK && (!sdkManager.actualHeadset || !previousHeadsetSDK || headsetSDK.GetType() != previousHeadsetSDK.GetType())) { var headsetTransform = headsetSDK.GetHeadset(); sdkManager.actualHeadset = (headsetTransform ? headsetTransform.gameObject : null); previousHeadsetSDK = headsetSDK; forceSaveScene = true; } var setPreviousControllerSDK = false; if (controllerSDK && (!sdkManager.actualLeftController || !previousControllerSDK || controllerSDK.GetType() != previousControllerSDK.GetType())) { var controllerLeft = controllerSDK.GetControllerLeftHand(true); sdkManager.actualLeftController = (controllerLeft ? controllerLeft : null); setPreviousControllerSDK = true; } if (controllerSDK && (!sdkManager.actualRightController || !previousControllerSDK || controllerSDK.GetType() != previousControllerSDK.GetType())) { var controllerRight = controllerSDK.GetControllerRightHand(true); sdkManager.actualRightController = (controllerRight ? controllerRight : null); setPreviousControllerSDK = true; } if (controllerSDK && (!sdkManager.modelAliasLeftController || !previousControllerSDK || controllerSDK.GetType() != previousControllerSDK.GetType())) { var controllerLeft = controllerSDK.GetControllerModel(SDK_BaseController.ControllerHand.Left); sdkManager.modelAliasLeftController = (controllerLeft ? controllerLeft : null); setPreviousControllerSDK = true; } if (controllerSDK && (!sdkManager.modelAliasRightController || !previousControllerSDK || controllerSDK.GetType() != previousControllerSDK.GetType())) { var controllerRight = controllerSDK.GetControllerModel(SDK_BaseController.ControllerHand.Right); sdkManager.modelAliasRightController = (controllerRight ? controllerRight : null); setPreviousControllerSDK = true; } if (setPreviousControllerSDK) { previousControllerSDK = controllerSDK; forceSaveScene = true; } if (forceSaveScene) { UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(UnityEngine.SceneManagement.SceneManager.GetActiveScene()); } }