示例#1
0
    void SteeringControllerAction()
    {
        steeringTrackPos  = SteamVR_Input.GetVector2(trackPadPos_steering, SteamVR_Input_Sources.Any, true);
        steeringTrackDown = SteamVR_Input.GetStateDown(trackPadClick_steering, SteamVR_Input_Sources.Any, true);
        steeringTrack     = SteamVR_Input.GetState(trackPadClick_steering, SteamVR_Input_Sources.Any, true);

        if (SteamVR_Input.GetStateDown(triggerClick_steering, SteamVR_Input_Sources.Any, true))
        {
            behaviourTool.Engage();
            steeringTriggerDown = true;
        }
        else if (steeringTrackDown && steeringTrackPos.y < 0.5f && steeringTrackPos.y > -0.5f)
        {
            if (steeringTrackPos.x < -0.5f)
            {
                behaviourTool.ChangePart(PlacementBehaviour.ToolsetControls.Left);
            }
            else if (steeringTrackPos.x > 0.5f)
            {
                behaviourTool.ChangePart(PlacementBehaviour.ToolsetControls.Right);
            }
        }
        else if (steeringTrack && steeringTrackPos.x < 0.5f && steeringTrackPos.x > -0.5f)
        {
            if (steeringTrackPos.y < -0.5f)
            {
                behaviourTool.ScrollPart(PlacementBehaviour.ToolsetControls.Down);
            }
            else if (steeringTrackPos.y > 0.5f)
            {
                behaviourTool.ScrollPart(PlacementBehaviour.ToolsetControls.Up);
            }
        }


        if (!SteamVR_Input.GetState(triggerClick_steering, SteamVR_Input_Sources.Any, true) && steeringTriggerDown)
        {
            behaviourTool.DisEngage();
            steeringTriggerDown = false;
        }
    }
    /// <summary>
    /// Update is called every frame, if the MonoBehaviour is enabled.
    /// </summary>
    void Update()
    {
        // Check if having your index finger streched is a requirement for touch detection.
        if (requiresOpenIndexFinger)
        {
            if (SteamVR_Input.GetStateDown("TouchIndex", SteamVR_Input_Sources.LeftHand) && hand.name == "LeftHand")
            {
                GetComponent <SphereCollider>().enabled = false;
            }
            else if (SteamVR_Input.GetStateUp("TouchIndex", SteamVR_Input_Sources.LeftHand) && hand.name == "LeftHand")
            {
                GetComponent <SphereCollider>().enabled = true;
            }

            if (SteamVR_Input.GetStateDown("TouchIndex", SteamVR_Input_Sources.RightHand) && hand.name == "RightHand")
            {
                GetComponent <SphereCollider>().enabled = false;
            }
            else if (SteamVR_Input.GetStateUp("TouchIndex", SteamVR_Input_Sources.RightHand) && hand.name == "RightHand")
            {
                GetComponent <SphereCollider>().enabled = true;
            }
        }

        // Check if the last button pressed is still highlighted after resting index finger on the controller (bug fix)
        if (!GetComponent <SphereCollider>().enabled)
        {
            if (lastButtonPressed)
            {
                if (lastButtonPressed.GetComponent <Image>().color != lastButtonPressed.colors.normalColor)
                {
                    // FIXME: Needs to be commented for multiple choice for Dialogue Tool plugin, but needs to be commented for other UI.
                    //lastButtonPressed.GetComponent<Image>().color = lastButtonPressed.colors.normalColor;
                }
            }
        }
    }
示例#3
0
    // Update is called once per frame
    void Update()
    {
        if (SteamVR_Input.GetStateDown("Reload", rightHand))
        {
            silver = 0;
        }

        if (silver > 0)
        {
            if (SteamVR_Input.GetStateDown("Pinch", rightHand))
            {
                Instantiate(particle, muzzle1);
                trriger.Play();
                anime.Play();
                casing();
                bullet();
                gun_audio.PlayOneShot(audio_shot);
                vibration.Execute(0, 0.1f, 100, 1f, rightHand);
                silver = silver - 1;
            }
        }
        else
        {
            if (SteamVR_Input.GetStateDown("Pinch", rightHand))
            {
                trriger.Play();
                gun_audio.PlayOneShot(audio_out);
            }
        }


        if (SteamVR_Input.GetStateDown("Grip", rightHand))
        {
            Destroy(HandGun);
        }
    }
示例#4
0
 private bool IsTriggerPressed()
 {
     return(SteamVR_Input.GetStateDown("InteractUI", SteamVR_Input_Sources.Any));
 }
    void Tutorial()
    {
        if (instructions[8].active)
        {
            return;
        }

        if (instructions[5].active || instructions[7].active)
        {
            if (SteamVR_Input.GetStateDown("InteractUI", SteamVR_Input_Sources.Any))
            {
                instructions[5].active = false;
                instructions[7].active = false;
                ResetInstructions();
                currentTrialGenerator.StartExperiment();
            }
        }

        if (instructions[4].active || instructions[6].active)
        {
            if (SteamVR_Input.GetStateDown("InteractUI", SteamVR_Input_Sources.Any))
            {
                instructions[4].active = false;
                instructions[6].active = false;
                ResetInstructions();
                currentTrialGenerator.StartExperiment();
            }
        }

        if (instructions[3].active)
        {
            if (SteamVR_Input.GetStateDown("InteractUI", SteamVR_Input_Sources.Any))
            {
                if (currentTrialGenerator.PreferenceMode == PreferenceMode.DEPTH)
                {
                    instructions[4].active = true;
                }
                else if (currentTrialGenerator.PreferenceMode == PreferenceMode.APPEARANCE)
                {
                    instructions[6].active = true;
                }
            }
        }

        if (instructions[2].active)
        {
            if (SteamVR_Input.GetStateDown("InteractUI", SteamVR_Input_Sources.Any))
            {
                CancelConfirmHint();
                showConfrimHint        = false;
                instructions[2].active = false;
                instructions[3].active = true;
            }
        }

        if (instructions[1].active)
        {
            if (SteamVR_Input.GetStateDown("Teleport", SteamVR_Input_Sources.Any))
            {
                instructions[1].active         = false;
                instructions[2].active         = true;
                enhancementScriptWolski.toggle = !enhancementScriptWolski.toggle;
                enhancementScriptWanat.toggle  = !enhancementScriptWolski.toggle;
                ConfirmHint();
            }
        }

        if (instructions[0].active)
        {
            if (showChangeModeHint && SteamVR_Input.GetStateDown("Teleport", SteamVR_Input_Sources.Any))
            {
                CancelChanegModeHint();
                showChangeModeHint             = false;
                instructions[0].active         = false;
                instructions[1].active         = true;
                enhancementScriptWolski.toggle = !enhancementScriptWolski.toggle;
                enhancementScriptWanat.toggle  = !enhancementScriptWolski.toggle;
            }
        }
    }
示例#6
0
 //-------------------------------------------------
 // Called every Update() while a Hand is hovering over this object
 //-------------------------------------------------
 private void HandHoverUpdate(Hand hand)
 {
     /*
      * if (isAvailable)
      * {
      *
      *  GrabTypes startingGrabType = hand.GetGrabStarting();
      *  bool isGrabEnding = hand.IsGrabEnding(this.gameObject);
      *
      *  if (interactable.attachedToHand == null && startingGrabType != GrabTypes.None)
      *  {
      *      if (activeSocket)
      *      {
      *          activeSocket.InteractSlot(hand);
      *          return;
      *      }
      *
      *      HandsAttached = 1;
      *      grabbingHand = hand;
      *      hand.HoverLock(interactable);
      *
      *      // Attach this object to the hand
      *      hand.AttachObject(gameObject, startingGrabType, attachmentFlags, grabposition);
      *  }
      *  else if (isGrabEnding)
      *  {
      *      // Detach this object from the hand
      *      hand.DetachObject(gameObject, restoreParent);
      *
      *      // Call this to undo HoverLock
      *      hand.HoverUnlock(interactable);
      *
      *
      *  }
      */
     if (isAvailable)
     {
         if (grabTypes == MyGrabTypes.Press)
         {
             if (SteamVR_Input.GetStateDown("Shoot", hand.handType))
             {
                 if (activeSocket)
                 {
                     activeSocket.InteractSlot(hand);
                     return;
                 }
                 if (hand.ObjectIsAttached(this.gameObject))
                 {
                     // Detach this object from the hand
                     hand.DetachObject(gameObject, restoreParent);
                     // Call this to undo HoverLock
                     hand.HoverUnlock(interactable);
                 }
                 else
                 {
                     HandsAttached = 1;
                     grabbingHand  = hand;
                     hand.HoverLock(interactable);
                     // Attach this object to the hand
                     hand.AttachObject(gameObject, GrabTypes.Scripted, attachmentFlags, grabposition);
                 }
             }
         }
         else if (grabTypes == MyGrabTypes.Hold)
         {
             if (SteamVR_Input.GetStateUp("Shoot", hand.handType))
             {
                 if (hand.ObjectIsAttached(this.gameObject))
                 {
                     // Detach this object from the hand
                     hand.DetachObject(gameObject, restoreParent);
                     // Call this to undo HoverLock
                     hand.HoverUnlock(interactable);
                 }
             }
             else if (SteamVR_Input.GetStateDown("Shoot", hand.handType))
             {
                 if (!hand.ObjectIsAttached(this.gameObject))
                 {
                     HandsAttached = 1;
                     grabbingHand  = hand;
                     hand.HoverLock(interactable);
                     // Attach this object to the hand
                     hand.AttachObject(gameObject, GrabTypes.Scripted, attachmentFlags, grabposition);
                 }
             }
         }
         else
         {
             if (SteamVR_Input.GetStateDown("Shoot", hand.handType))
             {
                 if (!hand.ObjectIsAttached(this.gameObject))
                 {
                     HandsAttached = 1;
                     grabbingHand  = hand;
                     hand.HoverLock(interactable);
                     // Attach this object to the hand
                     hand.AttachObject(gameObject, GrabTypes.Scripted, attachmentFlags, grabposition);
                 }
             }
         }
     }
 }