/** * Pomocna metoda ktora nastavi vsetkym ovladacom grab button na paramter * @param btn novy grab button */ private void SetGrabButton(VRTK_ControllerEvents.ButtonAlias btn) { foreach (var contoller in controlers) { contoller.grabButton = btn; } }
public void EnableEditorInput(VRTK_ControllerEvents.ButtonAlias button) { _vio.isGrabbable = true; var grab = _gameObject.GetComponent <VRTK_InteractControllerAppearance>(); if (grab == null) { grab = _gameObject.AddComponent <VRTK_InteractControllerAppearance>(); } grab.hideControllerOnGrab = true; _vio.secondaryGrabActionScript = _gameObject.GetComponent <VRTK_SwapControllerGrabAction>(); if (_vio.secondaryGrabActionScript == null) { _vio.secondaryGrabActionScript = _gameObject.AddComponent <VRTK_SwapControllerGrabAction>(); } VRTK_FixedJointGrabAttach vrtkFixedJointGrab = _gameObject.GetComponent <VRTK_FixedJointGrabAttach>(); if (vrtkFixedJointGrab == null) { vrtkFixedJointGrab = _gameObject.AddComponent <VRTK_FixedJointGrabAttach>(); vrtkFixedJointGrab.breakForce = Single.PositiveInfinity; } vrtkFixedJointGrab.precisionGrab = true; _vio.grabOverrideButton = button; _vio.InteractableObjectGrabbed += EditorGrabbed; _vio.InteractableObjectUngrabbed += EditorUngrabbed; _vio.InteractableObjectTouched += EditorToched; _vio.InteractableObjectTouched += EditorUnToched; }
protected override void OnEnable() { base.OnEnable(); touchpadFirstChange = true; otherTouchpadControlEnabledStateSet = false; coordniateButtonAlias = (coordinateAxis == VRTK_ControllerEvents.Vector2AxisAlias.Touchpad ? VRTK_ControllerEvents.ButtonAlias.TouchpadTouch : VRTK_ControllerEvents.ButtonAlias.TouchpadTwoTouch); }
protected virtual void OnEnable() { trackedObjects.Clear(); movementList.Clear(); previousYPositions.Clear(); initialGaze = Vector3.zero; currentDirection = Vector3.zero; previousDirection = Vector3.zero; averagePeriod = 60; currentSpeed = 0f; movementEngaged = false; previousEngageButton = engageButton; bodyPhysics = (bodyPhysics != null ? bodyPhysics : FindObjectOfType <VRTK_BodyPhysics>()); controllerLeftHand = VRTK_DeviceFinder.GetControllerLeftHand(); controllerRightHand = VRTK_DeviceFinder.GetControllerRightHand(); SetControllerListeners(controllerLeftHand, leftController, ref leftSubscribed); SetControllerListeners(controllerRightHand, rightController, ref rightSubscribed); headset = VRTK_DeviceFinder.HeadsetTransform(); SetControlOptions(controlOptions); playArea = VRTK_DeviceFinder.PlayAreaTransform(); // Initialize the lists. for (int i = 0; i < trackedObjects.Count; i++) { Transform trackedObj = trackedObjects[i]; VRTK_SharedMethods.AddDictionaryValue(movementList, trackedObj, new List <float>(), true); VRTK_SharedMethods.AddDictionaryValue(previousYPositions, trackedObj, trackedObj.transform.localPosition.y, true); } }
protected virtual void FixedUpdate() { CheckControllerState(controllerLeftHand, leftController, ref leftSubscribed, ref previousLeftControllerState); CheckControllerState(controllerRightHand, rightController, ref leftSubscribed, ref previousRightControllerState); previousEngageButton = engageButton; HandleFalling(); // If Move In Place is currently engaged. if (MovementActivated() && !currentlyFalling) { // Initialize the list average. float speed = Mathf.Clamp(((speedScale * 350) * (CalculateListAverage() / trackedObjects.Count)), 0f, maxSpeed); previousDirection = direction; direction = SetDirection(); // Update our current speed. currentSpeed = speed; } else if (currentSpeed > 0f) { currentSpeed -= (currentlyFalling ? fallingDeceleration : deceleration); } else { currentSpeed = 0f; direction = Vector3.zero; previousDirection = Vector3.zero; } SetDeltaTransformData(); MovePlayArea(direction, currentSpeed); }
protected virtual void OnEnable() { controllerThrustHistory = new Queue <Vector3>(); controllerMovementHistory = new Queue <Vector3>(); controllerDirectionHistory = new Queue <Vector3>(); previousEngageButton = engageButton; VRTK_leftController = VRTK_DeviceFinder.GetControllerLeftHand(); VRTK_rightController = VRTK_DeviceFinder.GetControllerRightHand(); actualLeftController = VRTK_DeviceFinder.GetControllerLeftHand(getActual: true); actualRightController = VRTK_DeviceFinder.GetControllerRightHand(getActual: true); if (!actualLeftController) { Debug.LogError("No left controller found. Make sure you attach the Controller GameObject to the Flight Handler."); } if (!actualRightController) { Debug.LogError("No right controller found. Make sure you attach the Controller GameObject to the Flight Handler."); } playAreaTransform = VRTK_DeviceFinder.PlayAreaTransform(); playerRigidbody = playAreaTransform.GetComponent <Rigidbody>(); SetControllerListeners(VRTK_leftController, leftController, ref leftSubscribed); SetControllerListeners(VRTK_rightController, rightController, ref rightSubscribed); }
protected virtual void UnsubscribeButtonEvent(VRTK_ControllerEvents.ButtonAlias buttonType, ControllerInteractionEventHandler eventHandler) { if (buttonType != VRTK_ControllerEvents.ButtonAlias.Undefined) { controllerEvents.UnsubscribeToButtonAliasEvent(buttonType, true, eventHandler); controllerEvents.UnsubscribeToButtonAliasEvent(buttonType, false, eventHandler); } }
private void OnEnable() { triggerRumble = false; CreateTouchCollider(); CreateTouchRigidBody(); originalGrabAlias = VRTK_ControllerEvents.ButtonAlias.Undefined; originalUseAlias = VRTK_ControllerEvents.ButtonAlias.Undefined; }
protected virtual void UnsubscribeSelectionButton() { if (controller && subscribedSelectionButton != VRTK_ControllerEvents.ButtonAlias.Undefined) { controller.UnsubscribeToButtonAliasEvent(subscribedSelectionButton, currentSelectOnPress, SelectionButtonAction); subscribedSelectionButton = VRTK_ControllerEvents.ButtonAlias.Undefined; } }
protected virtual void UnsubscribeActivationButton() { if (controllerEvents != null && subscribedActivationButton != VRTK_ControllerEvents.ButtonAlias.Undefined) { controllerEvents.UnsubscribeToButtonAliasEvent(subscribedActivationButton, true, DoActivationButtonPressed); controllerEvents.UnsubscribeToButtonAliasEvent(subscribedActivationButton, false, DoActivationButtonReleased); subscribedActivationButton = VRTK_ControllerEvents.ButtonAlias.Undefined; } }
protected virtual void UnsubscribeSelectionButton() { if (controller != null && subscribedSelectionButton != VRTK_ControllerEvents.ButtonAlias.Undefined) { controller.UnsubscribeToButtonAliasEvent(selectionButton, true, DoSelectionButtonPressed); controller.UnsubscribeToButtonAliasEvent(selectionButton, false, DoSelectionButtonReleased); controller.UnsubscribeToButtonAliasEvent(subscribedSelectionButton, currentSelectOnPress, SelectionButtonAction); subscribedSelectionButton = VRTK_ControllerEvents.ButtonAlias.Undefined; } }
protected virtual void SubscribeButtonEvent(VRTK_ControllerEvents.ButtonAlias buttonType, ref VRTK_ControllerEvents.ButtonAlias saveType, ControllerInteractionEventHandler setEventHandler, ControllerInteractionEventHandler resetEventHandler) { if (buttonType != VRTK_ControllerEvents.ButtonAlias.Undefined) { saveType = buttonType; controllerEvents.SubscribeToButtonAliasEvent(buttonType, true, setEventHandler); controllerEvents.SubscribeToButtonAliasEvent(buttonType, false, resetEventHandler); } }
protected virtual void ControllerUntouchInteractableObject(object sender, ObjectInteractEventArgs e) { if (e.target != null) { VRTK_InteractableObject touchedObjectScript = e.target.GetComponent <VRTK_InteractableObject>(); if (!touchedObjectScript.IsGrabbed() && savedGrabButton != VRTK_ControllerEvents.ButtonAlias.Undefined) { grabButton = savedGrabButton; savedGrabButton = VRTK_ControllerEvents.ButtonAlias.Undefined; } } }
protected virtual void ControllerTouchInteractableObject(object sender, ObjectInteractEventArgs e) { if (e.target != null) { VRTK_InteractableObject touchedObjectScript = e.target.GetComponent <VRTK_InteractableObject>(); if (touchedObjectScript != null && touchedObjectScript.grabOverrideButton != VRTK_ControllerEvents.ButtonAlias.Undefined) { savedGrabButton = subscribedGrabButton; grabButton = touchedObjectScript.grabOverrideButton; } } }
protected virtual void ControllerUntouchInteractableObject(object sender, ObjectInteractEventArgs e) { if (e.target != null) { VRTK_InteractableObject touchedObjectScript = e.target.GetComponent<VRTK_InteractableObject>(); if (touchedObjectScript != null && !touchedObjectScript.IsUsing() && savedUseButton != VRTK_ControllerEvents.ButtonAlias.Undefined) { useButton = savedUseButton; savedUseButton = VRTK_ControllerEvents.ButtonAlias.Undefined; ManageUseListener(true); } } }
private void ResetButtonOverrides() { if (originalGrabAlias != VRTK_ControllerEvents.ButtonAlias.Undefined) { controllerEvents.grabToggleButton = originalGrabAlias; originalGrabAlias = VRTK_ControllerEvents.ButtonAlias.Undefined; } if (originalUseAlias != VRTK_ControllerEvents.ButtonAlias.Undefined) { controllerEvents.useToggleButton = originalUseAlias; originalUseAlias = VRTK_ControllerEvents.ButtonAlias.Undefined; } }
private void ResetButtonOverrides(bool isGrabbed, bool isUsing) { if (!isGrabbed && originalGrabAlias != VRTK_ControllerEvents.ButtonAlias.Undefined) { controllerEvents.grabToggleButton = originalGrabAlias; originalGrabAlias = VRTK_ControllerEvents.ButtonAlias.Undefined; } if (!isUsing && originalUseAlias != VRTK_ControllerEvents.ButtonAlias.Undefined) { controllerEvents.useToggleButton = originalUseAlias; originalUseAlias = VRTK_ControllerEvents.ButtonAlias.Undefined; } }
// Init void Start() { intObj = GetComponent <VRTK_InteractableObject>(); intObj.InteractableObjectGrabbed += ObjectGrabbed; intObj.InteractableObjectGrabbed += ObjectUngrabbed; controlers = new List <VRTK_InteractGrab>(); foreach (var go in GameObject.FindGameObjectsWithTag("Controller")) { controlers.Add(go.GetComponent <VRTK_InteractGrab>()); } originalAliasGrab = controlers[0].grabButton; }
protected override void ControllerUntouchInteractableObject(object sender, ObjectInteractEventArgs e) { if (e.target != null) { e.target.GetComponent <Renderer>().material = untouchedMaterial; VRTK_InteractableObject touchedObjectScript = e.target.GetComponent <VRTK_InteractableObject>(); if (!touchedObjectScript.IsGrabbed() && savedGrabButton != VRTK_ControllerEvents.ButtonAlias.Undefined) { useButton = savedUseButton; savedUseButton = VRTK_ControllerEvents.ButtonAlias.Undefined; ManageUseListener(true); } } }
protected virtual void SubscribeActivationButton() { if (subscribedActivationButton != VRTK_ControllerEvents.ButtonAlias.Undefined) { UnsubscribeActivationButton(); } if (controller) { controller.SubscribeToButtonAliasEvent(activationButton, true, ActivationButtonPressed); controller.SubscribeToButtonAliasEvent(activationButton, false, ActivationButtonReleased); subscribedActivationButton = activationButton; } }
protected virtual void SubscribeSelectionButton() { if (subscribedSelectionButton != VRTK_ControllerEvents.ButtonAlias.Undefined) { UnsubscribeSelectionButton(); } if (controller) { controller.SubscribeToButtonAliasEvent(selectionButton, selectOnPress, SelectionButtonAction); subscribedSelectionButton = selectionButton; currentSelectOnPress = selectOnPress; } }
private void CheckButtonOverrides(VRTK_InteractableObject touchedObjectScript) { if (touchedObjectScript.grabOverrideButton != VRTK_ControllerEvents.ButtonAlias.Undefined) { originalGrabAlias = controllerEvents.grabToggleButton; controllerEvents.grabToggleButton = touchedObjectScript.grabOverrideButton; } if (touchedObjectScript.useOverrideButton != VRTK_ControllerEvents.ButtonAlias.Undefined) { originalUseAlias = controllerEvents.useToggleButton; controllerEvents.useToggleButton = touchedObjectScript.useOverrideButton; } }
protected override void ControllerTouchInteractableObject(object sender, ObjectInteractEventArgs e) { if (e.target != null) { untouchedMaterial = e.target.GetComponent <Renderer>().material; e.target.GetComponent <Renderer>().material = touchDebug; VRTK_InteractableObject touchedObjectScript = e.target.GetComponent <VRTK_InteractableObject>(); if (touchedObjectScript != null && touchedObjectScript.useOverrideButton != VRTK_ControllerEvents.ButtonAlias.Undefined) { savedUseButton = subscribedUseButton; useButton = touchedObjectScript.useOverrideButton; ManageUseListener(true); } } }
protected virtual void SubscribeActivationButton() { if (subscribedActivationButton != VRTK_ControllerEvents.ButtonAlias.Undefined) { UnsubscribeActivationButton(); } if (controller != null) { //Debug.Log("DoActivationButtonPressed is called "); controller.SubscribeToButtonAliasEvent(activationButton, true, DoActivationButtonPressed); controller.SubscribeToButtonAliasEvent(activationButton, false, DoActivationButtonReleased); subscribedActivationButton = activationButton; } }
protected virtual void SubscribeSelectionButton() { if (subscribedSelectionButton != VRTK_ControllerEvents.ButtonAlias.Undefined) { UnsubscribeSelectionButton(); } if (controllerEvents != null) { controllerEvents.SubscribeToButtonAliasEvent(selectionButton, true, DoSelectionButtonPressed); controllerEvents.SubscribeToButtonAliasEvent(selectionButton, false, DoSelectionButtonReleased); controllerEvents.SubscribeToButtonAliasEvent(selectionButton, selectOnPress, SelectionButtonAction); subscribedSelectionButton = selectionButton; currentSelectOnPress = selectOnPress; } }
protected virtual void ManageGrabListener(bool state) { if (controllerEvents != null && subscribedGrabButton != VRTK_ControllerEvents.ButtonAlias.Undefined && (!state || !grabButton.Equals(subscribedGrabButton))) { controllerEvents.UnsubscribeToButtonAliasEvent(subscribedGrabButton, true, DoGrabObject); controllerEvents.UnsubscribeToButtonAliasEvent(subscribedGrabButton, false, DoReleaseObject); subscribedGrabButton = VRTK_ControllerEvents.ButtonAlias.Undefined; } if (controllerEvents != null && state && grabButton != VRTK_ControllerEvents.ButtonAlias.Undefined && !grabButton.Equals(subscribedGrabButton)) { controllerEvents.SubscribeToButtonAliasEvent(grabButton, true, DoGrabObject); controllerEvents.SubscribeToButtonAliasEvent(grabButton, false, DoReleaseObject); subscribedGrabButton = grabButton; } }
protected virtual void ManageUseListener(bool state) { if (controllerEvents != null && subscribedUseButton != VRTK_ControllerEvents.ButtonAlias.Undefined && (!state || useButton != subscribedUseButton)) { controllerEvents.UnsubscribeToButtonAliasEvent(subscribedUseButton, true, DoStartUseObject); controllerEvents.UnsubscribeToButtonAliasEvent(subscribedUseButton, false, DoStopUseObject); subscribedUseButton = VRTK_ControllerEvents.ButtonAlias.Undefined; } if (controllerEvents != null && state && useButton != VRTK_ControllerEvents.ButtonAlias.Undefined && useButton != subscribedUseButton) { controllerEvents.SubscribeToButtonAliasEvent(useButton, true, DoStartUseObject); controllerEvents.SubscribeToButtonAliasEvent(useButton, false, DoStopUseObject); subscribedUseButton = useButton; } }
// Token: 0x060017BA RID: 6074 RVA: 0x0007EEAC File Offset: 0x0007D0AC protected virtual void SetDirectionListener(bool state, VRTK_ControllerEvents.ButtonAlias directionButton, ref VRTK_ControllerEvents.ButtonAlias subscribedDirectionButton, ControllerInteractionEventHandler pressCallback, ControllerInteractionEventHandler releaseCallback) { if (this.controllerEvents) { if (subscribedDirectionButton != VRTK_ControllerEvents.ButtonAlias.Undefined && (!state || directionButton == VRTK_ControllerEvents.ButtonAlias.Undefined || directionButton != subscribedDirectionButton)) { this.controllerEvents.UnsubscribeToButtonAliasEvent(subscribedDirectionButton, true, pressCallback); this.controllerEvents.UnsubscribeToButtonAliasEvent(subscribedDirectionButton, false, releaseCallback); subscribedDirectionButton = VRTK_ControllerEvents.ButtonAlias.Undefined; } if (state && directionButton != VRTK_ControllerEvents.ButtonAlias.Undefined && directionButton != subscribedDirectionButton) { this.controllerEvents.SubscribeToButtonAliasEvent(directionButton, true, pressCallback); this.controllerEvents.SubscribeToButtonAliasEvent(directionButton, false, releaseCallback); subscribedDirectionButton = directionButton; } } }
protected virtual void ManageActivationListener(bool state, ref VRTK_ControllerEvents.ButtonAlias activationButton, ref VRTK_ControllerEvents.ButtonAlias subscribedActivationButton, ControllerInteractionEventHandler buttonPressedCallback, ControllerInteractionEventHandler buttonReleasedCallback) { if (subscribedActivationButton == VRTK_ControllerEvents.ButtonAlias.Undefined && (!state || activationButton != subscribedActivationButton)) { if (leftControllerEvents != null) { leftControllerEvents.UnsubscribeToButtonAliasEvent(subscribedActivationButton, true, buttonPressedCallback); leftControllerEvents.UnsubscribeToButtonAliasEvent(subscribedActivationButton, false, buttonReleasedCallback); leftControllerEvents.ControllerModelAvailable -= ControllerModelAvailable; } if (rightControllerEvents != null) { rightControllerEvents.UnsubscribeToButtonAliasEvent(subscribedActivationButton, true, buttonPressedCallback); rightControllerEvents.UnsubscribeToButtonAliasEvent(subscribedActivationButton, false, buttonReleasedCallback); rightControllerEvents.ControllerModelAvailable -= ControllerModelAvailable; } subscribedActivationButton = VRTK_ControllerEvents.ButtonAlias.Undefined; } if (state && subscribedActivationButton == VRTK_ControllerEvents.ButtonAlias.Undefined && activationButton != VRTK_ControllerEvents.ButtonAlias.Undefined) { bool subscribed = false; if (leftControllerEvents != null) { leftControllerEvents.SubscribeToButtonAliasEvent(activationButton, true, buttonPressedCallback); leftControllerEvents.SubscribeToButtonAliasEvent(activationButton, false, buttonReleasedCallback); leftControllerEvents.ControllerModelAvailable += ControllerModelAvailable; subscribed = true; } if (rightControllerEvents != null) { rightControllerEvents.SubscribeToButtonAliasEvent(activationButton, true, buttonPressedCallback); rightControllerEvents.SubscribeToButtonAliasEvent(activationButton, false, buttonReleasedCallback); rightControllerEvents.ControllerModelAvailable += ControllerModelAvailable; subscribed = true; } if (subscribed) { subscribedActivationButton = activationButton; } } }
protected virtual void ManageActivationListeners(bool state) { if (controllerEvents != null) { if (subscribedActivationButton != VRTK_ControllerEvents.ButtonAlias.Undefined && (!state || activationButton != subscribedActivationButton)) { controllerEvents.UnsubscribeToButtonAliasEvent(subscribedActivationButton, true, DoActivationPress); controllerEvents.UnsubscribeToButtonAliasEvent(subscribedActivationButton, false, DoActivationRelease); subscribedActivationButton = VRTK_ControllerEvents.ButtonAlias.Undefined; } if (state && activationButton != VRTK_ControllerEvents.ButtonAlias.Undefined) { controllerEvents.SubscribeToButtonAliasEvent(activationButton, true, DoActivationPress); controllerEvents.SubscribeToButtonAliasEvent(activationButton, false, DoActivationRelease); subscribedActivationButton = activationButton; } } }