示例#1
0
 protected virtual void OnActionZoneEvent(ColliderZoneArgs args)
 {
     if (ActionZoneEvent != null)
     {
         ActionZoneEvent.Invoke(args);
     }
 }
示例#2
0
 protected virtual void OnContactZoneEvent(ColliderZoneArgs args)
 {
     if (ContactZoneEvent != null)
     {
         ContactZoneEvent.Invoke(args);
     }
 }
示例#3
0
 protected virtual void OnProximityZoneEvent(ColliderZoneArgs args)
 {
     if (ProximityZoneEvent != null)
     {
         ProximityZoneEvent.Invoke(args);
     }
 }
示例#4
0
        private void ActionOrInContactZoneStayEvent(ColliderZoneArgs collisionArgs)
        {
            if (!_buttonInContactOrActionStates || collisionArgs.CollidingTool.IsFarFieldTool)
            {
                return;
            }

            // calculate how much the button should be pushed inwards. based on contact zone.
            // assume collider is uniform 1x1x1 cube, and all scaling, etc is done on transform component
            // another way to test distances is to measure distance to plane that represents where
            // button translation must stop
            Vector3 buttonScale         = _buttonContactTransform.localScale;
            Vector3 interactionPosition = collisionArgs.CollidingTool.InteractionPosition;
            Vector3 localSpacePosition  = _buttonContactTransform.InverseTransformPoint(
                interactionPosition);
            // calculate offset in local space. so bias coordinates from 0.5,-0.5 to 0, -1.
            // 0 is no offset, 1.0 in local space is max offset pushing inwards
            Vector3 offsetVector = localSpacePosition - LOCAL_SIZE_HALVED * Vector3.one;
            // affect offset by button scale. only care about y (since y goes inwards)
            float scaledLocalSpaceOffset = offsetVector.y * buttonScale.y;

            // restrict button movement. can only go so far in negative direction, and cannot
            // be positive (which would cause the button to "stick out")
            if (scaledLocalSpaceOffset > -_contactMaxDisplacementDistance && scaledLocalSpaceOffset
                <= 0.0f)
            {
                transform.localPosition = new Vector3(_oldPosition.x, _oldPosition.y +
                                                      scaledLocalSpaceOffset, _oldPosition.z);
            }
        }
示例#5
0
 public InteractableStateArgs(Interactable interactable, InteractableTool tool,
                              InteractableState newInteractableState, InteractableState oldState,
                              ColliderZoneArgs colliderArgs)
 {
     Interactable         = interactable;
     Tool                 = tool;
     NewInteractableState = newInteractableState;
     OldInteractableState = oldState;
     ColliderArgs         = colliderArgs;
 }