protected virtual string GetElementPath(string currentPath, SDK_BaseController.ControllerElements elementType) { SDK_BaseController.ControllerHand currentHand = VRTK_DeviceFinder.GetControllerHand(actualController); string foundElementPath = VRTK_SDK_Bridge.GetControllerElementPath(elementType, currentHand); return(currentPath.Trim() == "" && foundElementPath != null ? foundElementPath : currentPath.Trim()); }
protected virtual void SetControllerAttachPoint() { //If no attach point has been specified then just use the tip of the controller if (controllerReference.model != null && originalControllerAttachPoint == null) { //attempt to find the attach point on the controller SDK_BaseController.ControllerHand handType = VRTK_DeviceFinder.GetControllerHand(interactTouch.gameObject); string elementPath = VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.AttachPoint, handType); Transform defaultAttachPoint = controllerReference.model.transform.Find(elementPath); if (defaultAttachPoint != null) { controllerAttachPoint = defaultAttachPoint.GetComponent <Rigidbody>(); if (controllerAttachPoint == null) { Rigidbody autoGenRB = defaultAttachPoint.gameObject.AddComponent <Rigidbody>(); autoGenRB.isKinematic = true; controllerAttachPoint = autoGenRB; } } } else if (originalControllerAttachPoint == null) { Debug.LogWarning("Grabbing object is missing an attach point; one will be auto-generated"); controllerAttachPoint = GetComponent <Rigidbody>(); if (controllerAttachPoint == null) { Rigidbody autoGenRB = gameObject.AddComponent <Rigidbody>(); autoGenRB.isKinematic = true; controllerAttachPoint = autoGenRB; } } }
// Token: 0x0600132E RID: 4910 RVA: 0x0006B720 File Offset: 0x00069920 public override GameObject GetControllerModel(SDK_BaseController.ControllerHand hand) { GameObject gameObject = this.GetSDKManagerControllerModelForHand(hand); if (gameObject == null) { GameObject gameObject2 = null; if (hand != SDK_BaseController.ControllerHand.Left) { if (hand == SDK_BaseController.ControllerHand.Right) { gameObject2 = this.GetControllerRightHand(true); } } else { gameObject2 = this.GetControllerLeftHand(true); } if (gameObject2 != null) { gameObject = gameObject2.transform.Find("Model").gameObject; } } return(gameObject); }
public void Release() { Cleanup(); targetHand = SDK_BaseController.ControllerHand.None; transform.SetParent(ComposeVRManager.Instance.transform); NoteSelectorHide.Raise(); }
public bool Request(SDK_BaseController.ControllerHand hand, int initialNote) { if (targetHand != SDK_BaseController.ControllerHand.None) { return(false); } targetHand = hand; if (targetHand == SDK_BaseController.ControllerHand.Left) { selectorFrame.transform.position = leftHandFrame.position; selectorFrame.transform.rotation = leftHandFrame.rotation; noteDisplay.transform.parent.localRotation = Quaternion.Euler(0, 0, 180); noteDisplay.transform.localRotation = Quaternion.Euler(0, 180, 0); } else { selectorFrame.transform.position = rightHandFrame.position; selectorFrame.transform.rotation = rightHandFrame.rotation; noteDisplay.transform.parent.localRotation = Quaternion.Euler(0, 0, 0); noteDisplay.transform.localRotation = Quaternion.Euler(0, 180, 0); } Init(initialNote); NoteSelectorShow.Raise(); return(true); }
private void PlayHapticTick() { //Use hand opposite the target hand for haptic feedback SDK_BaseController.ControllerHand hapticHand = targetHand == SDK_BaseController.ControllerHand.Right ? SDK_BaseController.ControllerHand.Left : SDK_BaseController.ControllerHand.Right; VRTK_ControllerHaptics.TriggerHapticPulse(VRTK_ControllerReference.GetControllerReference(hapticHand), TickStrength); }
/// <summary> /// The PopulateHighlighters method sets up the highlighters on the controller model. /// </summary> public virtual void PopulateHighlighters() { if (actualController != null) { highlighterOptions.Clear(); VRTK_SharedMethods.AddDictionaryValue(highlighterOptions, "resetMainTexture", true, true); autoHighlighter = false; baseHighlighter = GetValidHighlighter(); if (baseHighlighter == null) { autoHighlighter = true; baseHighlighter = actualController.AddComponent <VRTK_MaterialColorSwapHighlighter>(); } SDK_BaseController.ControllerHand currentHand = VRTK_DeviceFinder.GetControllerHand(actualController); baseHighlighter.Initialise(null, actualController, highlighterOptions); AddHighlighterToElement(GetElementTransform(VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.ButtonOne, currentHand)), baseHighlighter, elementHighlighterOverrides.buttonOne); AddHighlighterToElement(GetElementTransform(VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.ButtonTwo, currentHand)), baseHighlighter, elementHighlighterOverrides.buttonTwo); AddHighlighterToElement(GetElementTransform(VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.Body, currentHand)), baseHighlighter, elementHighlighterOverrides.body); AddHighlighterToElement(GetElementTransform(VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.GripLeft, currentHand)), baseHighlighter, elementHighlighterOverrides.gripLeft); AddHighlighterToElement(GetElementTransform(VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.GripRight, currentHand)), baseHighlighter, elementHighlighterOverrides.gripRight); AddHighlighterToElement(GetElementTransform(VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.StartMenu, currentHand)), baseHighlighter, elementHighlighterOverrides.startMenu); AddHighlighterToElement(GetElementTransform(VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.SystemMenu, currentHand)), baseHighlighter, elementHighlighterOverrides.systemMenu); AddHighlighterToElement(GetElementTransform(VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.Touchpad, currentHand)), baseHighlighter, elementHighlighterOverrides.touchpad); AddHighlighterToElement(GetElementTransform(VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.TouchpadTwo, currentHand)), baseHighlighter, elementHighlighterOverrides.touchpadTwo); AddHighlighterToElement(GetElementTransform(VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.Trigger, currentHand)), baseHighlighter, elementHighlighterOverrides.trigger); } }
protected virtual void CreateTouchCollider() { SDK_BaseController.ControllerHand controllerHand = VRTK_DeviceFinder.GetControllerHand(gameObject); Object defaultColliderPrefab = Resources.Load(VRTK_SDK_Bridge.GetControllerDefaultColliderPath(controllerHand)); if (customColliderContainer == null) { if (defaultColliderPrefab == null) { VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.SDK_OBJECT_NOT_FOUND, "default collider prefab", "Controller SDK")); return; } controllerCollisionDetector = Instantiate(defaultColliderPrefab, transform.position, transform.rotation) as GameObject; controllerCollisionDetector.transform.SetParent(transform); controllerCollisionDetector.transform.localScale = transform.localScale; controllerCollisionDetector.name = VRTK_SharedMethods.GenerateVRTKObjectName(true, "Controller", "CollidersContainer"); destroyColliderOnDisable = true; } else { if (CustomRigidBodyIsChild()) { controllerCollisionDetector = customColliderContainer; destroyColliderOnDisable = false; } else { controllerCollisionDetector = Instantiate(customColliderContainer, transform.position, transform.rotation) as GameObject; controllerCollisionDetector.transform.SetParent(transform); controllerCollisionDetector.transform.localScale = transform.localScale; destroyColliderOnDisable = true; } } controllerCollisionDetector.AddComponent <VRTK_PlayerObject>().objectType = VRTK_PlayerObject.ObjectTypes.Collider; }
// Token: 0x06001BA7 RID: 7079 RVA: 0x00090C2C File Offset: 0x0008EE2C public static bool IsControllerOfHand(GameObject checkController, SDK_BaseController.ControllerHand hand) { if (hand != SDK_BaseController.ControllerHand.Left) { return(hand == SDK_BaseController.ControllerHand.Right && VRTK_DeviceFinder.IsControllerRightHand(checkController)); } return(VRTK_DeviceFinder.IsControllerLeftHand(checkController)); }
//------------------------------------------------- private void FindBow() { SDK_BaseController.ControllerHand handType = VRTK_DeviceFinder.GetControllerHand(hand); GameObject bowGo; bowGo = otherHand.GetComponent <VRTK_InteractGrab>().GetGrabbedObject(); bow = bowGo.GetComponent <VRTKLongBow>(); //bow = hand.otherHand.GetComponentInChildren<VRTKLongBow>(); }
// Token: 0x06001344 RID: 4932 RVA: 0x0006BCD4 File Offset: 0x00069ED4 protected virtual string GetControllerStartMenuPath(SDK_BaseController.ControllerHand hand, string suffix) { VRTK_DeviceFinder.Headsets headsetType = VRTK_DeviceFinder.GetHeadsetType(true); if (headsetType != VRTK_DeviceFinder.Headsets.OculusRift) { return(null); } return(((hand == SDK_BaseController.ControllerHand.Left) ? "enter_button" : "home_button") + suffix); }
// Token: 0x06001597 RID: 5527 RVA: 0x0007693C File Offset: 0x00074B3C protected virtual void SetControllerAttachPoint() { if (this.controllerReference.model != null && this.originalControllerAttachPoint == null) { SDK_BaseController.ControllerHand controllerHand = VRTK_DeviceFinder.GetControllerHand(this.interactTouch.gameObject); string controllerElementPath = VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.AttachPoint, controllerHand, false); this.attemptSetCurrentControllerAttachPoint = base.StartCoroutine(this.SetCurrentControllerAttachPoint(controllerElementPath, 10, 0.1f)); } }
protected virtual void OnEnable() { cachedPointerAttachPoint = null; cachedAttachedHand = SDK_BaseController.ControllerHand.None; defaultMaterial = Resources.Load("WorldPointer") as Material; makeRendererVisible.Clear(); CreatePointerOriginTransformFollow(); CreatePointerObjects(); }
/// <summary> /// The IsValidInteractableController method is used to check to see if a controller is allowed to perform an interaction with this object as sometimes controllers are prohibited from grabbing or using an object depedning on the use case. /// </summary> /// <param name="actualController">The game object of the controller that is being checked.</param> /// <param name="controllerCheck">The value of which controller is allowed to interact with this object.</param> /// <returns>Is true if the interacting controller is allowed to grab the object.</returns> public virtual bool IsValidInteractableController(GameObject actualController, AllowedController controllerCheck) { if (controllerCheck == AllowedController.Both) { return(true); } SDK_BaseController.ControllerHand controllerHand = VRTK_DeviceFinder.GetControllerHandType(controllerCheck.ToString().Replace("Only", "")); return(VRTK_DeviceFinder.IsControllerOfHand(actualController, controllerHand)); }
// Token: 0x060015EA RID: 5610 RVA: 0x000779C8 File Offset: 0x00075BC8 protected virtual void OnEnable() { this.destroyColliderOnDisable = false; SDK_BaseController.ControllerHand controllerHand = VRTK_DeviceFinder.GetControllerHand(base.gameObject); this.defaultColliderPrefab = Resources.Load(VRTK_SDK_Bridge.GetControllerDefaultColliderPath(controllerHand)); VRTK_PlayerObject.SetPlayerObject(base.gameObject, VRTK_PlayerObject.ObjectTypes.Controller); this.triggerRumble = false; this.CreateTouchCollider(); this.CreateTouchRigidBody(); }
public static VRTK_ControllerReference GetControllerReference(SDK_BaseController.ControllerHand controllerHand) { GameObject scriptAlias = GetValidObjectFromHand(controllerHand); uint controllerIndex = VRTK_SDK_Bridge.GetControllerIndex(scriptAlias); if (controllerReferences.ContainsKey(controllerIndex)) { return(controllerReferences[controllerIndex]); } return(new VRTK_ControllerReference(scriptAlias)); }
// Token: 0x06001549 RID: 5449 RVA: 0x000757A0 File Offset: 0x000739A0 protected virtual string GetElementPath(string currentPath, SDK_BaseController.ControllerElements elementType) { SDK_BaseController.ControllerHand controllerHand = VRTK_DeviceFinder.GetControllerHand(this.controllerAlias); string controllerElementPath = VRTK_SDK_Bridge.GetControllerElementPath(elementType, controllerHand, false); if (!(currentPath.Trim() == "") || controllerElementPath == null) { return(currentPath.Trim()); } return(controllerElementPath); }
protected virtual Transform GetPointerOriginTransform() { VRTK_ControllerReference controllerReference = GetControllerReference(attachedTo); if (VRTK_ControllerReference.IsValid(controllerReference) && (cachedAttachedHand != controllerReference.hand || cachedPointerAttachPoint == null)) { cachedPointerAttachPoint = controllerReference.model.transform.Find(VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.AttachPoint, controllerReference.hand)); cachedAttachedHand = controllerReference.hand; } return(cachedPointerAttachPoint != null ? cachedPointerAttachPoint : transform); }
protected virtual void SetControllerAttachPoint() { //If no attach point has been specified then just use the tip of the controller if (controllerReference.model != null && originalControllerAttachPoint == null) { //attempt to find the attach point on the controller SDK_BaseController.ControllerHand handType = VRTK_DeviceFinder.GetControllerHand(interactTouch.gameObject); string elementPath = VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.AttachPoint, handType); attemptSetCurrentControllerAttachPoint = StartCoroutine(SetCurrentControllerAttachPoint(elementPath, 10, 0.1f)); } }
public static VRTK_ControllerReference GetControllerReference(SDK_BaseController.ControllerHand controllerHand) { GameObject scriptAlias = GetValidObjectFromHand(controllerHand); uint controllerIndex = VRTK_SDK_Bridge.GetControllerIndex(scriptAlias); VRTK_ControllerReference foundReference = VRTK_SharedMethods.GetDictionaryValue(controllerReferences, controllerIndex); if (foundReference != null) { return(foundReference); } return(new VRTK_ControllerReference(scriptAlias)); }
// Token: 0x06001364 RID: 4964 RVA: 0x0006C04A File Offset: 0x0006A24A public static GameObject GetControllerByHand(SDK_BaseController.ControllerHand hand, bool actual) { if (hand == SDK_BaseController.ControllerHand.Left) { return(VRTK_SDK_Bridge.GetControllerLeftHand(actual)); } if (hand != SDK_BaseController.ControllerHand.Right) { return(null); } return(VRTK_SDK_Bridge.GetControllerRightHand(actual)); }
/// <summary> /// The GetOppositeHand method returns the other hand type from the current hand given. /// </summary> /// <param name="currentHand">The current hand.</param> /// <returns>The opposite hand.</returns> public static SDK_BaseController.ControllerHand GetOppositeHand(SDK_BaseController.ControllerHand currentHand) { switch (currentHand) { case SDK_BaseController.ControllerHand.Left: return(SDK_BaseController.ControllerHand.Right); case SDK_BaseController.ControllerHand.Right: return(SDK_BaseController.ControllerHand.Left); } return(currentHand); }
private static GameObject GetValidObjectFromHand(SDK_BaseController.ControllerHand controllerHand) { switch (controllerHand) { case SDK_BaseController.ControllerHand.Left: return(VRTK_SDK_Bridge.GetControllerLeftHand(false) ? VRTK_SDK_Bridge.GetControllerLeftHand(false) : VRTK_SDK_Bridge.GetControllerLeftHand(true)); case SDK_BaseController.ControllerHand.Right: return(VRTK_SDK_Bridge.GetControllerRightHand(false) ? VRTK_SDK_Bridge.GetControllerRightHand(false) : VRTK_SDK_Bridge.GetControllerRightHand(true)); } return(null); }
public static GameObject GetControllerByHand(SDK_BaseController.ControllerHand hand, bool actual) { switch (hand) { case SDK_BaseController.ControllerHand.Left: return(GetControllerLeftHand(actual)); case SDK_BaseController.ControllerHand.Right: return(GetControllerRightHand(actual)); } return(null); }
/// <summary> /// The IsControllerOfHand method is used to check if a given controller game object is of the hand type provided. /// </summary> /// <param name="checkController">The actual controller object that is being checked.</param> /// <param name="hand">The representation of a hand to check if the given controller matches.</param> /// <returns>Is true if the given controller matches the given hand.</returns> public static bool IsControllerOfHand(GameObject checkController, SDK_BaseController.ControllerHand hand) { switch (hand) { case SDK_BaseController.ControllerHand.Left: return(IsControllerLeftHand(checkController)); case SDK_BaseController.ControllerHand.Right: return(IsControllerRightHand(checkController)); } return(false); }
// Token: 0x06001342 RID: 4930 RVA: 0x0006BC54 File Offset: 0x00069E54 protected virtual string GetControllerButtonTwoPath(SDK_BaseController.ControllerHand hand, string suffix) { VRTK_DeviceFinder.Headsets headsetType = VRTK_DeviceFinder.GetHeadsetType(true); if (headsetType == VRTK_DeviceFinder.Headsets.OculusRift) { return(((hand == SDK_BaseController.ControllerHand.Left) ? "y_button" : "b_button") + suffix); } if (headsetType == VRTK_DeviceFinder.Headsets.Vive) { return("button" + suffix); } return(null); }
// Token: 0x06001340 RID: 4928 RVA: 0x0006BBE8 File Offset: 0x00069DE8 protected virtual string GetControllerTouchpadPath(SDK_BaseController.ControllerHand hand, string suffix) { VRTK_DeviceFinder.Headsets headsetType = VRTK_DeviceFinder.GetHeadsetType(true); if (headsetType == VRTK_DeviceFinder.Headsets.OculusRift) { return("thumbstick" + suffix); } if (headsetType == VRTK_DeviceFinder.Headsets.Vive) { return("trackpad" + suffix); } return(null); }
// Token: 0x0600133F RID: 4927 RVA: 0x0006BBA8 File Offset: 0x00069DA8 protected virtual string GetControllerGripPath(SDK_BaseController.ControllerHand hand, string suffix, SDK_BaseController.ControllerHand forceHand) { VRTK_DeviceFinder.Headsets headsetType = VRTK_DeviceFinder.GetHeadsetType(true); if (headsetType == VRTK_DeviceFinder.Headsets.OculusRift) { return("grip" + suffix); } if (headsetType == VRTK_DeviceFinder.Headsets.Vive) { return(((forceHand == SDK_BaseController.ControllerHand.Left) ? "lgrip" : "rgrip") + suffix); } return(null); }
protected virtual void RegisterHandControllerListener(bool register, SDK_BaseController.ControllerHand givenHand) { switch (givenHand) { case SDK_BaseController.ControllerHand.Left: ManageLeftControllerListener(register, ControllerModelReady); break; case SDK_BaseController.ControllerHand.Right: ManageRightControllerListener(register, ControllerModelReady); break; } controllerModelWaitSubscribed = register; }
/// <summary> /// The ConfigureControllerPaths method is used to set up the model element paths. /// </summary> public virtual void ConfigureControllerPaths() { cachedElements = new Dictionary <string, Transform>(); SDK_BaseController.ControllerHand controllerHand = VRTK_DeviceFinder.GetControllerHand(controllerAlias); modelElementPaths.bodyModelPath = GetElementPath(modelElementPaths.bodyModelPath, SDK_BaseController.ControllerElements.Body); modelElementPaths.triggerModelPath = GetElementPath(modelElementPaths.triggerModelPath, SDK_BaseController.ControllerElements.Trigger); modelElementPaths.leftGripModelPath = GetElementPath(modelElementPaths.leftGripModelPath, SDK_BaseController.ControllerElements.GripLeft); modelElementPaths.rightGripModelPath = GetElementPath(modelElementPaths.rightGripModelPath, SDK_BaseController.ControllerElements.GripRight); modelElementPaths.touchpadModelPath = GetElementPath(modelElementPaths.touchpadModelPath, SDK_BaseController.ControllerElements.Touchpad); modelElementPaths.buttonOneModelPath = GetElementPath(modelElementPaths.buttonOneModelPath, SDK_BaseController.ControllerElements.ButtonOne); modelElementPaths.buttonTwoModelPath = GetElementPath(modelElementPaths.buttonTwoModelPath, SDK_BaseController.ControllerElements.ButtonTwo); modelElementPaths.systemMenuModelPath = GetElementPath(modelElementPaths.systemMenuModelPath, SDK_BaseController.ControllerElements.SystemMenu); modelElementPaths.startMenuModelPath = GetElementPath(modelElementPaths.systemMenuModelPath, SDK_BaseController.ControllerElements.StartMenu); }