public override void StartReaction(object o, EventArgs e) { InteractionAreaEventArgs interactionAreaEventArgs = e as InteractionAreaEventArgs; if (interactionAreaEventArgs != null) { // See if there is more data that is needed for this reaction if (interactionAreaEventArgs.hasMoreReactionInfo) { SnapEventArgSender snapEventSender = interactionAreaEventArgs.interactionObject.GetComponent <SnapEventArgSender>(); if (snapEventSender != null) { SnapReactionEventArgs snapEventArgs = snapEventSender.GetEventArgs() as SnapReactionEventArgs; SnapObject(snapEventArgs.interactionObject, snapEventArgs.snapLocation, snapEventArgs.keepObjectGrabbable); } else { SnapObject(interactionAreaEventArgs.interactionObject); } } else { SnapObject(interactionAreaEventArgs.interactionObject); } } }
private GameObject GetControllerModelFromEvent(EventArgs e) { InteractionAreaEventArgs interactionAreaEventArgs = e as InteractionAreaEventArgs; if (interactionAreaEventArgs != null) { if (interactionAreaEventArgs.hasMoreReactionInfo) { ControllerEventArgSender eventArgsSender = interactionAreaEventArgs.interactionObject.GetComponent <ControllerEventArgSender>(); if (eventArgsSender != null) { ControllerReactionEventArgs eventArgs = eventArgsSender.GetEventArgs() as ControllerReactionEventArgs; return(VRTK_DeviceFinder.GetModelAliasController(eventArgs.interactingController)); } } } return(null); }
public override void StartReaction(object o, EventArgs e) { InteractionAreaEventArgs interactionAreaEventArgs = e as InteractionAreaEventArgs; if (interactionAreaEventArgs != null) { // Look at the GrabAction to find if the piece that activated the reaction is the one that was originally removed RemovePieceGrabAction removeAction = gameObject.GetComponentInParent <RemovePieceGrabAction>(); if (removeAction.secondaryInteractableToRemove.gameObject == interactionAreaEventArgs.interactionObject) { // See if there is a Parent Constraint, if so, uses that to set the parent ParentConstraint parentConstraint = interactionAreaEventArgs.interactionObject.GetComponent <ParentConstraint>(); if (parentConstraint != null) { ConstraintSource parentConstraintSource = new ConstraintSource(); parentConstraintSource.sourceTransform = removeAction.transform; parentConstraintSource.weight = 1.0f; parentConstraint.AddSource(parentConstraintSource); parentConstraint.SetTranslationOffset(0, localPosition); parentConstraint.constraintActive = true; } // Otherwise, default to transform parent else { interactionAreaEventArgs.interactionObject.transform.parent = removeAction.transform; } // Deactive the collider and rigidbody on the secondary IO so that the main object can be grabbed again interactionAreaEventArgs.interactionObject.GetComponentInChildren <Collider>().enabled = false; interactionAreaEventArgs.interactionObject.GetComponentInChildren <Rigidbody>().useGravity = false; interactionAreaEventArgs.interactionObject.GetComponentInChildren <VRTK_InteractableObject>().isGrabbable = false; // After this has been returned, deactive the IA so that it cannot be triggered again gameObject.SetActive(false); } } }
protected void OnDependentInteractionArea(object sender, InteractionAreaEventArgs e) { awaitingEvents.Remove(sender as InteractionArea); CheckDependencyCount(); }