protected static void SetupInstance() { if (instance == null && VRTK_SDKManager.ValidInstance()) { instance = VRTK_SDKManager.instance.gameObject.AddComponent <VRTK_ControllerHaptics>(); } }
protected virtual void LoadedSetupChanged(VRTK_SDKManager sender, VRTK_SDKManager.LoadedSetupChangeEventArgs e) { if (VRTK_SDKManager.ValidInstance() && gameObject.activeInHierarchy) { ChildToSDKObject(); } }
protected static void SetupInstance() { if (instance == null && VRTK_SDKManager.ValidInstance()) { instance = VRTK_SDKManager.instance.gameObject.AddComponent <VRTK_ObjectAppearance>(); } }
protected virtual void LoadedSetupChanged(VRTK_SDKManager sender, VRTK_SDKManager.LoadedSetupChangeEventArgs e) { if (this != null && VRTK_SDKManager.ValidInstance() && gameObject.activeInHierarchy) { SetCanvasCamera(); } }
private void OnEnable() { #pragma warning disable 618 if (VRTK_SDKManager.ValidInstance() && !VRTK_SDKManager.instance.persistOnLoad) #pragma warning restore 618 { PopulateObjectReferences(false); } }
private void SetupControllers() { Action <GameObject, GameObject> setParent = (scriptAliasGameObject, actualGameObject) => { if (scriptAliasGameObject == null) { return; } Transform scriptAliasTransform = scriptAliasGameObject.transform; Transform actualTransform = actualGameObject.transform; if (scriptAliasTransform.parent != actualTransform) { Vector3 previousScale = scriptAliasTransform.localScale; scriptAliasTransform.SetParent(actualTransform); scriptAliasTransform.localScale = previousScale; } scriptAliasTransform.localPosition = Vector3.zero; scriptAliasTransform.localRotation = Quaternion.identity; }; if (actualLeftController != null && VRTK_SDKManager.ValidInstance()) { setParent(VRTK_SDKManager.instance.scriptAliasLeftController, actualLeftController); if (actualLeftController.GetComponent <VRTK_TrackedController>() == null) { actualLeftController.AddComponent <VRTK_TrackedController>(); } } if (actualRightController != null && VRTK_SDKManager.ValidInstance()) { setParent(VRTK_SDKManager.instance.scriptAliasRightController, actualRightController); if (actualRightController.GetComponent <VRTK_TrackedController>() == null) { actualRightController.AddComponent <VRTK_TrackedController>(); } } }
/// <summary> /// The PopulateObjectReferences method populates the object references by using the currently set SDKs. /// </summary> /// <param name="force">Whether to ignore `autoPopulateObjectReferences` while deciding to populate.</param> public void PopulateObjectReferences(bool force) { if (!(force || autoPopulateObjectReferences)) { return; } #if UNITY_EDITOR if (!EditorApplication.isPlaying && VRTK_SDKManager.ValidInstance()) { VRTK_SDKManager.instance.SetLoadedSDKSetupToPopulateObjectReferences(this); } #endif VRTK_SDK_Bridge.InvalidateCaches(); #if UNITY_EDITOR Undo.RecordObject(this, "Populate Object References"); #endif actualBoundaries = null; actualHeadset = null; actualLeftController = null; actualRightController = null; modelAliasLeftController = null; modelAliasRightController = null; 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); }
/// <summary> /// The PopulateObjectReferences method populates the object references by using the currently set SDKs. /// </summary> /// <param name="force">Whether to ignore `autoPopulateObjectReferences` while deciding to populate.</param> public void PopulateObjectReferences(bool force) { if (!(force || autoPopulateObjectReferences)) { return; } #if UNITY_EDITOR if (!EditorApplication.isPlaying && VRTK_SDKManager.ValidInstance()) { VRTK_SDKManager.instance.SetLoadedSDKSetupToPopulateObjectReferences(this); } #endif VRTK_SDK_Bridge.InvalidateCaches(); #if UNITY_EDITOR Undo.RecordObject(this, "Populate Object References"); #endif actualBoundaries = null; actualHeadset = null; actualLeftController = null; actualRightController = null; modelAliasLeftController = null; modelAliasRightController = null; actualTrackers = new List <GameObject>(); actualHand = null; Transform playAreaTransform = boundariesSDK.GetPlayArea(); Transform headsetTransform = headsetSDK.GetHeadset(); Transform handTransform = handSDK.GetRootTransform(); actualBoundaries = playAreaTransform == null ? null : playAreaTransform.gameObject; actualHeadset = headsetTransform == null ? null : headsetTransform.gameObject; actualLeftController = controllerSDK.GetControllerLeftHand(true); actualRightController = controllerSDK.GetControllerRightHand(true); actualHand = handTransform == null ? null : handTransform.gameObject; modelAliasLeftController = controllerSDK.GetControllerModel(SDK_BaseController.ControllerHand.Left); modelAliasRightController = controllerSDK.GetControllerModel(SDK_BaseController.ControllerHand.Right); GameObject[] trackerObjects = trackerSDK.GetAllTrackers(); if (trackerObjects != null) { foreach (GameObject tracker in trackerObjects) { if (!(tracker.Equals(actualHeadset) || tracker.Equals(actualLeftController) || tracker.Equals(actualRightController) #if VRTK_DEFINE_STEAMVR_PLUGIN_2_0_0_OR_NEWER || tracker.GetComponent <Valve.VR.SteamVR_TrackedObject>().index == Valve.VR.SteamVR_TrackedObject.EIndex.Hmd #elif VRTK_DEFINE_SDK_STEAMVR || tracker.GetComponent <SteamVR_TrackedObject>().index == SteamVR_TrackedObject.EIndex.Hmd #endif )) { // for now, we are not including HMDs or controllers in this list. We will revisit later, depending on the // progress of gesture recognition and Oculus integration levels. See JIRA ticket VIRTUOSO-119 for details actualTrackers.Add(tracker); } } } }