コード例 #1
0
 /// <summary>
 /// Called when a valid object enters the collider for the InteractionArea.
 /// </summary>
 /// <param name="e">The event arguments that holds a reference to the InteractableObject.</param>
 public virtual void OnObjectEnteredInteractionArea(InteractionAreaEventArgs e)
 {
     if (ObjectEnteredInteractionArea != null)
     {
         ObjectEnteredInteractionArea(this, e);
     }
 }
コード例 #2
0
        private void ChildEnterInteractionArea(object sender, InteractionAreaEventArgs interactionEvent)
        {
            checkInsideCylinder = true;

            InteractionArea area = sender as InteractionArea;

            interactableObject = interactionEvent.interactionObject;

            // Keep track of which child you're on
            completionCount = area.transform.GetSiblingIndex();
            pointToCheck    = interactableObject.transform.Find("Point");

            // Start condition - Only want to send this once on the first visit
            if (completionCount == 0)
            {
                MoveToNextCylinder();

                OnObjectUsedInteractionArea(SetInteractionAreaEvent(interactableObject));
            }
            // End condition - Last IA in the children was reached
            else if (completionCount == childrenAreas.Count - 1)
            {
                checkInsideCylinder = false;

                StartState();

                OnObjectFinishedInteractionArea(SetInteractionAreaEvent(interactableObject));
            }
            else
            {
                MoveToNextCylinder();
            }
        }
コード例 #3
0
        protected void ChildInteractionFinished(object o, InteractionAreaEventArgs e)
        {
            int childIndex = (o as InteractionArea).transform.GetSiblingIndex();

            childrenAreas[childIndex].ObjectFinishedInteractionArea -= ChildInteractionFinished;

            // Disable the collider on the interaction area so no one else can hit it
            Collider childCollider = childrenAreas[childIndex].gameObject.GetComponent <Collider>();

            if (childCollider != null)
            {
                childCollider.enabled = false;
            }

            completionCount++;

            if (completionCount == childrenAreas.Count)
            {
                OnObjectFinishedInteractionArea(SetInteractionAreaEvent(gameObject));
            }
            else if (enforceOrder)
            {
                SwitchChildren(completionCount);
            }
        }
コード例 #4
0
        public virtual void OnObjectInterruptInteractionArea(InteractionAreaEventArgs e)
        {
            interactionStarted = false;

            if (ObjectInterruptInteractionArea != null)
            {
                ObjectInterruptInteractionArea(this, e);
            }
        }
コード例 #5
0
        /// <summary>
        /// Called when the interaction event has started in the InteractionArea.
        /// </summary>
        /// <param name="e">The event arguments that holds a reference to the InteractableObject.</param>
        public virtual void OnObjectUsedInteractionArea(InteractionAreaEventArgs e)
        {
            interactionStarted = true;

            if (ObjectUsedInteractionArea != null)
            {
                ObjectUsedInteractionArea(this, e);
            }
        }
コード例 #6
0
        public override void OnObjectEnteredInteractionArea(InteractionAreaEventArgs e)
        {
            base.OnObjectEnteredInteractionArea(e);

            if (currentInteractionObject != null && e.interactionObject == currentInteractionObject.gameObject)
            {
                InteractionEnter(currentInteractionObject.gameObject);
            }
        }
コード例 #7
0
        public override void OnObjectEnteredInteractionArea(InteractionAreaEventArgs e)
        {
            base.OnObjectEnteredInteractionArea(e);

            if (currentInteractionObject != null)
            {
                // Get the starting directions to go off of
                previousFrameForwardDirection = currentInteractionObject.transform.forward;
                previousFrameRightDirection   = currentInteractionObject.transform.right;

                isTurnable = true;
            }
        }
コード例 #8
0
        /// <summary>
        /// Sets the given GameObject and returns the Arguments for an InteractableEvent. This method should be
        /// called whenever using one of the 'On' Event Handleing methods.
        /// </summary>
        /// <param name="interactableObject">The GameObject that is triggering the event in the InteractionArea.</param>
        /// <returns></returns>
        public static InteractionAreaEventArgs SetInteractionAreaEvent(GameObject interactableObject)
        {
            VRTK_InteractableObject ioCheck = interactableObject.GetComponent <VRTK_InteractableObject>();
            bool interactableHasExtraArgs   = false;

            if (ioCheck != null)
            {
                interactableHasExtraArgs = ioCheck.HasExtraEventArgs;
            }

            InteractionAreaEventArgs e = new InteractionAreaEventArgs
            {
                interactionObject   = interactableObject,
                hasMoreReactionInfo = interactableHasExtraArgs
            };

            return(e);
        }
コード例 #9
0
        public override void OnObjectExitedInteractionArea(InteractionAreaEventArgs e)
        {
            base.OnObjectExitedInteractionArea(e);

            InteractionExit(e.interactionObject);
        }
コード例 #10
0
 private void ObjectFinishedInteractionArea(object o, InteractionAreaEventArgs e)
 {
     OnObjectFinishedInteraction.Invoke(o, e);
 }
コード例 #11
0
 private void ObjectUnusedInteractionArea(object o, InteractionAreaEventArgs e)
 {
     OnObjectInterruptInteraction.Invoke(o, e);
 }
コード例 #12
0
 private void ObjectUsedInteractionArea(object o, InteractionAreaEventArgs e)
 {
     OnObjectStartInteraction.Invoke(o, e);
 }
コード例 #13
0
 private void ObjectExitedInteractionArea(object o, InteractionAreaEventArgs e)
 {
     OnObjectExitedInteractionArea.Invoke(o, e);
 }
コード例 #14
0
        public override void OnObjectExitedInteractionArea(InteractionAreaEventArgs e)
        {
            base.OnObjectExitedInteractionArea(e);

            isTurnable = false;
        }