示例#1
0
    // Starts interacting with an interactable component.
    public void StartInteracting(SteamVR_Input_Sources fromSource, IInteractableState interaction)
    {
        if (GetControllerState(fromSource).Interacting != interaction)
        {
            // If already interacting with an item, then stop interacting with it.
            if (GetControllerState(fromSource).Interacting != null)
            {
                StopInteracting(fromSource);
            }

            // Start interacting with the new item.
            Transform controller = GetController(fromSource).transform;
            interaction.StartInteraction(controller);
            interaction.Interrupted += Interaction_OnInterrupted;

            var startedInteractingState = GetControllerState(fromSource).NewInteractingState(interaction);
            SetControllerState(fromSource, startedInteractingState);
        }
    }
示例#2
0
 // Creates a new state with the given information.
 public ControllerState NewInteractingState(IInteractableState newInteracting)
 {
     return(new ControllerState(Squeezing, Holding, newInteracting));
 }
示例#3
0
 // Defines an immutable instance of this struct.
 public ControllerState(bool squeezing, IHoldable holding, IInteractableState interacting)
 {
     Squeezing   = squeezing;
     Holding     = holding;
     Interacting = interacting;
 }