Inheritance: Grabber
コード例 #1
0
	void HandHoverUpdate( VRHand hand )
	{
		if ( hand.GetStandardInteractionButtonDown() )
		{
			VRInputModule.instance.Submit( gameObject );
		}
	}
コード例 #2
0
 void HandHoverUpdate(VRHand hand)
 {
     if (hand.GetStandardInteractionButtonDown())
     {
         VRInputModule.instance.Submit(gameObject);
     }
 }
コード例 #3
0
    void OnDetachedFromHand(VRHand hand)
    {
        attached = false;

        hand.HoverUnlock(null);

        Rigidbody rb = GetComponent <Rigidbody>();

        rb.isKinematic   = false;
        rb.interpolation = RigidbodyInterpolation.Interpolate;

        velocityEstimator.FinishEstimatingVelocity();
        Vector3 velocity        = velocityEstimator.GetVelocityEstimate();
        Vector3 angularVelocity = velocityEstimator.GetAngularVelocityEstimate();

        rb.velocity        = velocity;
        rb.angularVelocity = angularVelocity;

        // Make the object travel at the release velocity for the amount
        // of time it will take until the next fixed update, at which
        // point Unity physics will take over
        float timeUntilFixedUpdate = (Time.fixedDeltaTime + Time.fixedTime) - Time.time;

        transform.position += timeUntilFixedUpdate * velocity;
        float   angle = Mathf.Rad2Deg * angularVelocity.magnitude;
        Vector3 axis  = angularVelocity.normalized;

        transform.rotation *= Quaternion.AngleAxis(angle * timeUntilFixedUpdate, axis);
    }
コード例 #4
0
 //-----------------------------------------------------
 void HandHoverUpdate(VRHand hand)
 {
     if (hand.GetStandardInteractionButtonDown())
     {
         PhysicsAttach(hand);
     }
 }
コード例 #5
0
ファイル: VRHand.cs プロジェクト: Black4Blade/ViveUGUIModule
    // Custom Inspector GUI allows us to click from within the UI
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        VRHand vrHand = ( VRHand )target;

        if (vrHand.otherHand)
        {
            if (vrHand.otherHand.otherHand != vrHand)
            {
                UnityEditor.EditorGUILayout.HelpBox("The otherHand of this VRHand's otherHand is not this VRHand.", UnityEditor.MessageType.Warning);
            }

            if (vrHand.startingHandType == VRHand.HandType.Left && vrHand.otherHand.startingHandType != VRHand.HandType.Right)
            {
                UnityEditor.EditorGUILayout.HelpBox("This is a left VRHand but otherHand is not a right VRHand.", UnityEditor.MessageType.Warning);
            }

            if (vrHand.startingHandType == VRHand.HandType.Right && vrHand.otherHand.startingHandType != VRHand.HandType.Left)
            {
                UnityEditor.EditorGUILayout.HelpBox("This is a right VRHand but otherHand is not a left VRHand.", UnityEditor.MessageType.Warning);
            }

            if (vrHand.startingHandType == VRHand.HandType.Any && vrHand.otherHand.startingHandType != VRHand.HandType.Any)
            {
                UnityEditor.EditorGUILayout.HelpBox("This is an any-handed VRHand but otherHand is not an any-handed VRHand.", UnityEditor.MessageType.Warning);
            }
        }
    }
コード例 #6
0
    /// <summary>
    /// Called every Update() while a VRHand is hovering over me.
    /// </summary>
    /// <param name="hand"></param>
    void HandHoverUpdate(VRHand hand)
    {
        if (hand.GetStandardInteractionButtonDown() || ((hand.controller != null) && hand.controller.GetPressDown(Valve.VR.EVRButtonId.k_EButton_Grip)))
        {
            if (hand.currentAttachedObject != gameObject)
            {
                // Save our position/rotation so that we can restore it when we detach
                oldPosition = transform.position;
                oldRotation = transform.rotation;

                // Call this to continue receiving HandHoverUpdate messages,
                // and prevent the hand from hovering over anything else
                hand.HoverLock(GetComponent <VRInteractable>());

                // Attach this object to the hand
                hand.AttachObject(gameObject, attachmentFlags);
            }
            else
            {
                // Detach this object from the hand
                hand.DetachObject(gameObject);

                // Call this to undo HoverLock
                hand.HoverUnlock(GetComponent <VRInteractable>());

                // Restore position/rotation
                transform.position = oldPosition;
                transform.rotation = oldRotation;
            }
        }
    }
コード例 #7
0
	void OnHandHoverBegin( VRHand hand )
	{
		bool showHint = true;

		// "Catch" the throwable by holding down the interaction button instead of pressing it.
		// Only do this if the throwable is moving faster than the prescribed threshold speed,
		// and if it isn't attached to another hand
		if ( !attached )
		{
			if ( hand.GetStandardInteractionButton() )
			{
				Rigidbody rb = GetComponent<Rigidbody>();
				if ( rb.velocity.magnitude >= catchSpeedThreshold )
				{
					hand.AttachObject( gameObject, attachmentFlags, attachmentPoint );
					showHint = false;
				}
			}
		}

		if ( showHint )
		{
			VRControllerButtonHints.Show( hand, Valve.VR.EVRButtonId.k_EButton_SteamVR_Trigger );
		}
	}
コード例 #8
0
    void OnHandHoverBegin(VRHand hand)
    {
        bool showHint = true;

        // "Catch" the throwable by holding down the interaction button instead of pressing it.
        // Only do this if the throwable is moving faster than the prescribed threshold speed,
        // and if it isn't attached to another hand
        if (!attached)
        {
            if (hand.GetStandardInteractionButton())
            {
                Rigidbody rb = GetComponent <Rigidbody>();
                if (rb.velocity.magnitude >= catchSpeedThreshold)
                {
                    hand.AttachObject(gameObject, attachmentFlags, attachmentPoint);
                    showHint = false;
                }
            }
        }

        if (showHint)
        {
            VRControllerButtonHints.Show(hand, Valve.VR.EVRButtonId.k_EButton_SteamVR_Trigger);
        }
    }
コード例 #9
0
    //-----------------------------------------------------
    private bool PhysicsDetach(VRHand hand)
    {
        int i = holdingHands.IndexOf(hand);

        if (i != -1)
        {
            // Detach this object from the hand
            holdingHands[i].DetachObject(this.gameObject, false);

            // Allow the hand to do other things
            holdingHands[i].HoverUnlock(null);

            // Delete any existing joints from the hand
            if (attachMode == AttachMode.FixedJoint)
            {
                Destroy(holdingHands[i].GetComponent <FixedJoint>());
            }

            FastRemove(holdingHands, i);
            FastRemove(holdingBodies, i);
            FastRemove(holdingPoints, i);

            return(true);
        }

        return(false);
    }
コード例 #10
0
	//-----------------------------------------------------
	void HandHoverUpdate( VRHand hand )
	{
		if ( requireTriggerPress && hand.GetStandardInteractionButtonDown() )
		{
			SpawnAndAttachObject( hand );
		}
	}
コード例 #11
0
    void OnHandHoverBegin(VRHand hand)
    {
        anim.Play();
        Globals.radioIsOn = !Globals.radioIsOn;

        Debug.Log(Globals.radioIsOn);
    }
コード例 #12
0
	/// <summary>
	/// Called every Update() while a VRHand is hovering over me.
	/// </summary>
	/// <param name="hand"></param>
	void HandHoverUpdate( VRHand hand )
	{
		if ( hand.GetStandardInteractionButtonDown() || ( ( hand.controller != null ) && hand.controller.GetPressDown( Valve.VR.EVRButtonId.k_EButton_Grip ) ) )
		{
			if ( hand.currentAttachedObject != gameObject )
			{
				// Save our position/rotation so that we can restore it when we detach
				oldPosition = transform.position;
				oldRotation = transform.rotation;

				// Call this to continue receiving HandHoverUpdate messages,
				// and prevent the hand from hovering over anything else
				hand.HoverLock( GetComponent<VRInteractable>() );

				// Attach this object to the hand
				hand.AttachObject( gameObject, false );
			}
			else
			{
				// Detach this object from the hand
				hand.DetachObject( gameObject );

				// Call this to undo HoverLock
				hand.HoverUnlock( GetComponent<VRInteractable>() );

				// Restore position/rotation
				transform.position = oldPosition;
				transform.rotation = oldRotation;
			}
		}
	}
コード例 #13
0
 //-----------------------------------------------------
 void HandHoverUpdate(VRHand hand)
 {
     if (requireTriggerPress && hand.GetStandardInteractionButtonDown())
     {
         SpawnAndAttachObject(hand);
     }
 }
コード例 #14
0
    void OnDrawGizmos()
    {
        if (this != instance)
        {
            return;
        }

        Gizmos.color = Color.green;
        Gizmos.DrawIcon(feetPositionGuess, "vr_interaction_system_feet.png");

        Gizmos.color = Color.cyan;
        Gizmos.DrawLine(feetPositionGuess, feetPositionGuess + trackingOriginTransform.up * eyeHeight);

        // Body direction arrow
        Gizmos.color = Color.blue;
        Vector3 bodyDirection        = bodyDirectionGuess;
        Vector3 bodyDirectionTangent = Vector3.Cross(trackingOriginTransform.up, bodyDirection);
        Vector3 startForward         = feetPositionGuess + trackingOriginTransform.up * eyeHeight * 0.75f;
        Vector3 endForward           = startForward + bodyDirection * 0.33f;

        Gizmos.DrawLine(startForward, endForward);
        Gizmos.DrawLine(endForward, endForward - 0.033f * (bodyDirection + bodyDirectionTangent));
        Gizmos.DrawLine(endForward, endForward - 0.033f * (bodyDirection - bodyDirectionTangent));

        Gizmos.color = Color.red;
        int count = handCount;

        for (int i = 0; i < count; i++)
        {
            VRHand hand = GetHand(i);

            if (hand.startingHandType == VRHand.HandType.Left)
            {
                Gizmos.DrawIcon(hand.transform.position, "vr_interaction_system_left_hand.png");
            }
            else if (hand.startingHandType == VRHand.HandType.Right)
            {
                Gizmos.DrawIcon(hand.transform.position, "vr_interaction_system_right_hand.png");
            }
            else
            {
                VRHand.HandType guessHandType = hand.GuessCurrentHandType();

                if (guessHandType == VRHand.HandType.Left)
                {
                    Gizmos.DrawIcon(hand.transform.position, "vr_interaction_system_left_hand_question.png");
                }
                else if (guessHandType == VRHand.HandType.Right)
                {
                    Gizmos.DrawIcon(hand.transform.position, "vr_interaction_system_right_hand_question.png");
                }
                else
                {
                    Gizmos.DrawIcon(hand.transform.position, "vr_interaction_system_unknown_hand.png");
                }
            }

            Gizmos.DrawIcon(hand.transform.position, "right_hand_question.png");
        }
    }
コード例 #15
0
    void OnHandHoverBegin(VRHand hand)
    {
        anim.Play();
        Globals.radioIsOn = !Globals.radioIsOn;

        Debug.Log(Globals.radioIsOn);
    }
コード例 #16
0
	void OnDetachedFromHand( VRHand hand )
	{
		attached = false;

		hand.HoverUnlock( null );

		Rigidbody rb = GetComponent<Rigidbody>();
		rb.isKinematic = false;
		rb.interpolation = RigidbodyInterpolation.Interpolate;

		velocityEstimator.FinishEstimatingVelocity();
		Vector3 velocity = velocityEstimator.GetVelocityEstimate();
		Vector3 angularVelocity = velocityEstimator.GetAngularVelocityEstimate();
		rb.velocity = velocity;
		rb.angularVelocity = angularVelocity;

		// Make the object travel at the release velocity for the amount
		// of time it will take until the next fixed update, at which
		// point Unity physics will take over
		float timeUntilFixedUpdate = ( Time.fixedDeltaTime + Time.fixedTime ) - Time.time;
		transform.position += timeUntilFixedUpdate * velocity;
		float angle = Mathf.Rad2Deg * angularVelocity.magnitude;
		Vector3 axis = angularVelocity.normalized;
		transform.rotation *= Quaternion.AngleAxis( angle * timeUntilFixedUpdate, axis );
	}
コード例 #17
0
 void HandAttachedUpdate(VRHand hand)
 {
     //Trigger got released
     if (hand.GetStandardInteractionButtonUp())
     {
         hand.DetachObject(gameObject);
     }
 }
コード例 #18
0
 void HandAttachedUpdate( VRHand hand )
 {
     //Trigger got released
     if ( hand.GetStandardInteractionButtonUp() )
     {
         hand.DetachObject( gameObject );
     }
 }
コード例 #19
0
 void HandHoverUpdate(VRHand hand)
 {
     //Trigger got pressed
     if (hand.GetStandardInteractionButtonDown())
     {
         hand.AttachObject(gameObject, snapOnAttach, attachmentPoint, detachOthers);
     }
 }
コード例 #20
0
	void HandHoverUpdate( VRHand hand )
	{
		//Trigger got pressed
		if ( hand.GetStandardInteractionButtonDown() )
		{
			hand.AttachObject( gameObject, snapOnAttach, attachmentPoint, detachOthers );
		}
	}
コード例 #21
0
 //-----------------------------------------------------
 void OnHandHoverBegin(VRHand hand)
 {
     Debug.Log("OnHoverBegin");
     if (!requireTriggerPress)
     {
         SpawnAndAttachObject(hand);
     }
 }
コード例 #22
0
	//-----------------------------------------------------
	void OnHandHoverBegin( VRHand hand )
	{
		Debug.Log( "OnHoverBegin" );
		if ( !requireTriggerPress )
		{
			SpawnAndAttachObject( hand );
		}
	}
コード例 #23
0
	void HandHoverUpdate( VRHand hand )
	{
		//Trigger got pressed
		if ( hand.GetStandardInteractionButtonDown() )
		{
			hand.AttachObject( gameObject, attachmentFlags, attachmentPoint );
			VRControllerButtonHints.Hide( hand );
		}
	}
コード例 #24
0
 void HandHoverUpdate(VRHand hand)
 {
     //Trigger got pressed
     if (hand.GetStandardInteractionButtonDown())
     {
         hand.AttachObject(gameObject, attachmentFlags, attachmentPoint);
         VRControllerButtonHints.Hide(hand);
     }
 }
コード例 #25
0
    //-----------------------------------------------------
    private void SpawnAndAttachObject(VRHand hand)
    {
        if (!alreadySpawned)
        {
            GameObject objectToAttach = GameObject.Instantiate(objectToSpawn);
            hand.AttachObject(objectToAttach, snapOnAttach, attachmentPoint, detachOthers);

            alreadySpawned = true;
        }
    }
コード例 #26
0
 //-----------------------------------------------------
 void OnHandHoverEnd(VRHand hand)
 {
     if (holdingHands.IndexOf(hand) == -1)
     {
         if (hand.controller != null)
         {
             hand.controller.TriggerHapticPulse(500);
         }
     }
 }
コード例 #27
0
	//-----------------------------------------------------
	private void SpawnAndAttachObject( VRHand hand )
	{
		if ( !alreadySpawned )
		{
			GameObject objectToAttach = GameObject.Instantiate( objectToSpawn );
			hand.AttachObject( objectToAttach, snapOnAttach, attachmentPoint, detachOthers );

			alreadySpawned = true;
		}
	}
コード例 #28
0
 public static void Show(VRHand hand, params Valve.VR.EVRButtonId[] buttons)
 {
     if (hand != null)
     {
         VRControllerButtonHints hints = hand.GetComponentInChildren <VRControllerButtonHints>();
         if (hints != null)
         {
             hints.Show(buttons);
         }
     }
 }
コード例 #29
0
 void OnHandHoverBegin(VRHand hand)
 {
     if(Globals.ritualSequence.Count >= 3)
     {
         Globals.ritualSequence[2] = true;
     }
     anim.Play();
     pianoAudio.Play();
     Globals.buttonPressed = !Globals.buttonPressed;
     Debug.Log(Globals.buttonPressed);
 }
コード例 #30
0
 void OnHandHoverBegin(VRHand hand)
 {
     if (Globals.ritualSequence.Count >= 3)
     {
         Globals.ritualSequence[2] = true;
     }
     anim.Play();
     pianoAudio.Play();
     Globals.buttonPressed = !Globals.buttonPressed;
     Debug.Log(Globals.buttonPressed);
 }
コード例 #31
0
 public static void Hide(VRHand hand)
 {
     if (hand != null)
     {
         VRControllerButtonHints hints = hand.GetComponentInChildren <VRControllerButtonHints>();
         if (hints != null)
         {
             hints.Hide();
         }
     }
 }
コード例 #32
0
	void OnAttachedToHand( VRHand hand )
	{
		attached = true;

		hand.HoverLock( null );
		
		Rigidbody rb = GetComponent<Rigidbody>();
		rb.isKinematic = true;
		rb.interpolation = RigidbodyInterpolation.None;

		velocityEstimator.BeginEstimatingVelocity();
	}
コード例 #33
0
    //-----------------------------------------------------
    public void PhysicsAttach(VRHand hand)
    {
        PhysicsDetach(hand);

        Rigidbody holdingBody  = null;
        Vector3   holdingPoint = Vector3.zero;

        // The hand should grab onto the nearest rigid body
        float closestDistance = float.MaxValue;

        for (int i = 0; i < rigidBodies.Count; i++)
        {
            float distance = Vector3.Distance(rigidBodies[i].worldCenterOfMass, hand.transform.position);
            if (distance < closestDistance)
            {
                holdingBody     = rigidBodies[i];
                closestDistance = distance;
            }
        }

        // Couldn't grab onto a body
        if (holdingBody == null)
        {
            return;
        }

        // Create a fixed joint from the hand to the holding body
        if (attachMode == AttachMode.FixedJoint)
        {
            Rigidbody handRigidbody = FindOrAddComponent <Rigidbody>(hand.gameObject);
            handRigidbody.isKinematic = true;

            FixedJoint handJoint = hand.gameObject.AddComponent <FixedJoint>();
            handJoint.connectedBody = holdingBody;
        }

        // Don't let the hand interact with other things while it's holding us
        hand.HoverLock(null);

        // Affix this point
        Vector3 offset = hand.transform.position - holdingBody.worldCenterOfMass;

        offset       = Mathf.Min(offset.magnitude, 1.0f) * offset.normalized;
        holdingPoint = holdingBody.transform.InverseTransformPoint(holdingBody.worldCenterOfMass + offset);

        hand.AttachObject(this.gameObject, attachmentFlags);

        // Update holding list
        holdingHands.Add(hand);
        holdingBodies.Add(holdingBody);
        holdingPoints.Add(holdingPoint);
    }
コード例 #34
0
    void OnAttachedToHand(VRHand hand)
    {
        attached = true;

        hand.HoverLock(null);

        Rigidbody rb = GetComponent <Rigidbody>();

        rb.isKinematic   = true;
        rb.interpolation = RigidbodyInterpolation.None;

        velocityEstimator.BeginEstimatingVelocity();
    }
コード例 #35
0
    void OnDetachedFromHand( VRHand hand )
    {
        attached = false;

        hand.HoverUnlock( null );

        Rigidbody rb = GetComponent<Rigidbody>();
        rb.isKinematic = false;
        rb.interpolation = RigidbodyInterpolation.Interpolate;

        velocityEstimator.FinishEstimatingVelocity();
        rb.velocity = velocityEstimator.GetVelocityEstimate();
        rb.angularVelocity = velocityEstimator.GetAngularVelocityEstimate();
    }
コード例 #36
0
 void OnHandHoverBegin(VRHand hand)
 {
     if (!activated)
     {
         anim.Play();
         coffeeAreaCollider.enabled = true;
         coffeeFlowRenderer.enabled = true;
         thisRenderer.material      = usedMaterial;
         activated = true;
         Debug.Log("Enabled Coffee Area Collider");
         coffeeFlowAudioSource.Play();
         endTime = timeValidSeconds + Time.time;
     }
 }
コード例 #37
0
 void HandAttachedUpdate(VRHand hand)
 {
     //Trigger got released
     if (hand.GetStandardInteractionButtonUp())
     {
         // Detach ourselves late in the frame.
         // This is so that any vehicles the player is attached to
         // have a chance to finish updating themselves.
         // If we detach now, our position could be behind what it
         // will be at the end of the frame, and the object may appear
         // to teleport behind the hand when the player releases it.
         StartCoroutine(LateDetach(hand));
     }
 }
コード例 #38
0
    public void OnTriggerExit(Collider other)
    {
        VRHand hand = other.GetComponent <VRHand>();

        if (hand != null)
        {
            animator.SetBool("isPressed", false);

            if (OnButtonReleased != null)
            {
                OnButtonReleased.Invoke();
            }
        }
    }
コード例 #39
0
    void OnHandHoverBegin(VRHand hand)
    {
    	if (!activated)
    	{
	    	anim.Play();
	        coffeeAreaCollider.enabled = true;
	        coffeeFlowRenderer.enabled = true;
	        thisRenderer.material = usedMaterial;
	        activated = true;
	        Debug.Log("Enabled Coffee Area Collider");
	        coffeeFlowAudioSource.Play();
	        endTime = timeValidSeconds + Time.time;
	    }
    }
コード例 #40
0
    void Update()
    {
        for (int i = 0; i < VRPlayer.instance.handCount; i++)
        {
            VRHand hand = VRPlayer.instance.GetHand(i);

            if (hand.controller != null)
            {
                if (hand.controller.GetPressDown(Valve.VR.EVRButtonId.k_EButton_SteamVR_Trigger))
                {
                    onTriggerDown.Invoke();
                }

                if (hand.controller.GetPressUp(Valve.VR.EVRButtonId.k_EButton_SteamVR_Trigger))
                {
                    onTriggerUp.Invoke();
                }

                if (hand.controller.GetPressDown(Valve.VR.EVRButtonId.k_EButton_Grip))
                {
                    onGripDown.Invoke();
                }

                if (hand.controller.GetPressUp(Valve.VR.EVRButtonId.k_EButton_Grip))
                {
                    onGripUp.Invoke();
                }

                if (hand.controller.GetPressDown(Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad))
                {
                    onTouchpadDown.Invoke();
                }

                if (hand.controller.GetPressUp(Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad))
                {
                    onTouchpadUp.Invoke();
                }

                if (hand.controller.GetTouchDown(Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad))
                {
                    onTouchpadTouch.Invoke();
                }

                if (hand.controller.GetTouchUp(Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad))
                {
                    onTouchpadRelease.Invoke();
                }
            }
        }
    }
コード例 #41
0
    void OnDetachedFromHand(VRHand hand)
    {
        attached = false;

        hand.HoverUnlock(null);

        Rigidbody rb = GetComponent <Rigidbody>();

        rb.isKinematic   = false;
        rb.interpolation = RigidbodyInterpolation.Interpolate;

        velocityEstimator.FinishEstimatingVelocity();
        rb.velocity        = velocityEstimator.GetVelocityEstimate();
        rb.angularVelocity = velocityEstimator.GetAngularVelocityEstimate();
    }
コード例 #42
0
ファイル: VRPlayer.cs プロジェクト: LeeviPaa/VRJAMGAME
    void Start()
    {
        VRHand[] hands = GetComponentsInChildren <VRHand>();

        for (int i = 0; i < hands.Length; i++)
        {
            if (hands[i].hand == VRHand.ControllerIndex.Left)
            {
                leftHand = hands[i];
            }
            else if (hands[i].hand == VRHand.ControllerIndex.Right)
            {
                rightHand = hands[i];
            }
        }
    }
コード例 #43
0
    private VRHand thisHand;                // Referencia a la mano para detectar si estamos pulsando un botón o no.

    /// <summary>
    /// Evento Start de MonoBehavior.
    /// Se ejecuta una vez al inicio.
    /// </summary>
    virtual public void Start()
    {
        if (reticle == null)
        {
            return;
        }

        // El componente Selection.cs también está pensado para estar asociado a la cámara.
        uiSelection = GetComponent <UISelection>();

        // Almacenamos el tamaño y la orientación original de la retícula.
        originalScale    = reticle.localScale;
        originalRotation = reticle.localRotation;

        thisHand = GetComponent <VRHand>();
    }
コード例 #44
0
 void OnEnable()
 {
     _hand = (VRHand)target;
     AToggle = _hand.UseAxis;
     BToggle = _hand.UseButton;
     grabPointProperty = serializedObject.FindProperty("GrabPoint");
     deviceIDProperty = serializedObject.FindProperty("DeviceID");
     animProperty = serializedObject.FindProperty("Animator");
     grabModeProperty = serializedObject.FindProperty("grabMode");
     useAxisProperty = serializedObject.FindProperty("UseAxis");
     axisIDProperty = serializedObject.FindProperty("GrabAxis");
     grabThresholdProperty = serializedObject.FindProperty("GrabThreshold");
     useButtonProperty = serializedObject.FindProperty("UseButton");
     buttonIDProperty = serializedObject.FindProperty("GrabButton");
     grabSpeedProperty = serializedObject.FindProperty("GrabSpeed");
 }
コード例 #45
0
	void HandHoverUpdate ( VRHand hand )
	{
		if ( hand.controller != null )
		{
			SteamVR_Controller.Device controller = hand.controller;

			if ( controller.GetPressDown( Valve.VR.EVRButtonId.k_EButton_SteamVR_Trigger ) )
			{
				onTriggerDown.Invoke();
			}

			if ( controller.GetPressUp( Valve.VR.EVRButtonId.k_EButton_SteamVR_Trigger ) )
			{
				onTriggerUp.Invoke();
			}

			if ( controller.GetPressDown( Valve.VR.EVRButtonId.k_EButton_Grip ) )
			{
				onGripDown.Invoke();
			}

			if ( controller.GetPressUp( Valve.VR.EVRButtonId.k_EButton_Grip ) )
			{
				onGripUp.Invoke();
			}

			if ( controller.GetPressDown( Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad ) )
			{
				onTouchpadDown.Invoke();
			}

			if ( controller.GetPressUp( Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad ) )
			{
				onTouchpadUp.Invoke();
			}

			if ( controller.GetTouchDown( Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad ) )
			{
				onTouchpadTouch.Invoke();
			}

			if ( controller.GetTouchUp( Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad ) )
			{
				onTouchpadRelease.Invoke();
			}
		}
	}
コード例 #46
0
    void HandHoverUpdate(VRHand hand)
    {
        if (hand.controller != null)
        {
            SteamVR_Controller.Device controller = hand.controller;

            if (controller.GetPressDown(Valve.VR.EVRButtonId.k_EButton_SteamVR_Trigger))
            {
                onTriggerDown.Invoke();
            }

            if (controller.GetPressUp(Valve.VR.EVRButtonId.k_EButton_SteamVR_Trigger))
            {
                onTriggerUp.Invoke();
            }

            if (controller.GetPressDown(Valve.VR.EVRButtonId.k_EButton_Grip))
            {
                onGripDown.Invoke();
            }

            if (controller.GetPressUp(Valve.VR.EVRButtonId.k_EButton_Grip))
            {
                onGripUp.Invoke();
            }

            if (controller.GetPressDown(Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad))
            {
                onTouchpadDown.Invoke();
            }

            if (controller.GetPressUp(Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad))
            {
                onTouchpadUp.Invoke();
            }

            if (controller.GetTouchDown(Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad))
            {
                onTouchpadTouch.Invoke();
            }

            if (controller.GetTouchUp(Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad))
            {
                onTouchpadRelease.Invoke();
            }
        }
    }
コード例 #47
0
	void OnHandHoverBegin( VRHand hand )
	{
		// "Catch" the throwable by holding down the interaction button instead of pressing it.
		// Only do this if the throwable is moving faster than the prescribed threshold speed,
		// and if it isn't attached to another hand
		if ( !attached )
		{
			if ( hand.GetStandardInteractionButton() )
			{
				Rigidbody rb = GetComponent<Rigidbody>();
				if ( rb.velocity.magnitude >= catchSpeedThreshold )
				{
					hand.AttachObject( gameObject, snapOnAttach, attachmentPoint, detachOthers );
				}
			}
		}
	}
コード例 #48
0
 void OnHandHoverBegin(VRHand hand)
 {
     // "Catch" the throwable by holding down the interaction button instead of pressing it.
     // Only do this if the throwable is moving faster than the prescribed threshold speed,
     // and if it isn't attached to another hand
     if (!attached)
     {
         if (hand.GetStandardInteractionButton())
         {
             Rigidbody rb = GetComponent <Rigidbody>();
             if (rb.velocity.magnitude >= catchSpeedThreshold)
             {
                 hand.AttachObject(gameObject, snapOnAttach, attachmentPoint, detachOthers);
             }
         }
     }
 }
コード例 #49
0
    void HandHoverUpdate( VRHand hand )
    {
        if ( hand.currentAttachedObject )
            return;

        if ( hand.GetStandardInteractionButtonDown() )
        {
            hand.HoverLock( GetComponent<VRInteractable>() );
        }

        if ( hand.GetStandardInteractionButtonUp() )
        {
            hand.HoverUnlock( GetComponent<VRInteractable>() );
        }

        if ( hand.GetStandardInteractionButton() )
        {
            UpdateLinearMapping( hand.transform );
        }
    }
コード例 #50
0
	void HandHoverUpdate( VRHand hand )
	{
		if ( hand.GetStandardInteractionButtonDown() )
		{
			hand.HoverLock( GetComponent<VRInteractable>() );

			initialMappingOffset = linearMapping.value - CalculateLinearMapping( hand.transform );
			sampleCount = 0;
			mappingChangeRate = 0.0f;
		}

		if ( hand.GetStandardInteractionButtonUp() )
		{
			hand.HoverUnlock( GetComponent<VRInteractable>() );

			CalculateMappingChangeRate();
		}

		if ( hand.GetStandardInteractionButton() )
		{
			UpdateLinearMapping( hand.transform );
		}
	}
コード例 #51
0
	void OnDetachedFromHand( VRHand hand )
	{
		attached = false;

		hand.HoverUnlock( null );

		Rigidbody rb = GetComponent<Rigidbody>();
		rb.isKinematic = false;
		rb.interpolation = RigidbodyInterpolation.Interpolate;

		velocityEstimator.FinishEstimatingVelocity();
		Vector3 velocity = velocityEstimator.GetVelocityEstimate();
		Vector3 angularVelocity = velocityEstimator.GetAngularVelocityEstimate();
		rb.velocity = velocity;
		rb.angularVelocity = angularVelocity;

		// Make the object travel at the release velocity for the amount
		// of time it will take until the next fixed update, at which
		// point physics will happily take over simulation
		float t = ( Time.fixedDeltaTime + Time.fixedTime ) - Time.time;
		transform.position += t * velocity;
		// TODO: update transform.rotation? probably too subtle, but should be fixed
		// TODO: verify the fix using large fixed timestep, determine if the warning should be deleted
	}
コード例 #52
0
	/// <summary>
	/// Called when a VRHand stops hovering over me.
	/// </summary>
	/// <param name="hand"></param>
	void OnHandHoverEnd( VRHand hand )
	{
		textMesh.text = "No Hand Hovering";
	}
コード例 #53
0
	/// <summary>
	/// Called every Update() while our GameObject is attached to the hand
	/// </summary>
	/// <param name="hand"></param>
	void HandAttachedUpdate( VRHand hand )
	{

	}
コード例 #54
0
	/// <summary>
	/// Called when our GameObject detaches from the hand
	/// </summary>
	/// <param name="hand"></param>
	void OnDetachedFromHand( VRHand hand )
	{
		textMesh.text = "Detached from hand: " + hand.name;
	}
コード例 #55
0
	/// <summary>
	/// Called when our GameObject becomes attached to the hand
	/// </summary>
	/// <param name="hand"></param>
	void OnAttachedToHand( VRHand hand )
	{
		textMesh.text = "Attached to hand: " + hand.name;
	}
コード例 #56
0
	//-----------------------------------------------------
	void OnHandHoverEnd( VRHand hand )
	{
		Debug.Log( "OnHandHoverEnd" );
		alreadySpawned = false;
	}
コード例 #57
0
	/// <summary>
	/// Called when our attached GameObject becomes the primary attached object
	/// </summary>
	/// <param name="hand"></param>
	void OnHandFocusAcquired( VRHand hand )
	{

	}
コード例 #58
0
	/// <summary>
	/// Called when a VRHand starts hovering over me.
	/// </summary>
	/// <param name="hand"></param>
	void OnHandHoverBegin( VRHand hand )
	{
		textMesh.text = "Hovering hand: " + hand.name;
	}
コード例 #59
0
 void OnHandHoverBegin(VRHand hand)
 {
     anim.Play();
     Globals.buttonPressed = !Globals.buttonPressed;
 }
コード例 #60
0
	/// <summary>
	/// Called when another attached GameObject becomes the primary attached object
	/// </summary>
	/// <param name="hand"></param>
	void OnHandFocusLost( VRHand hand )
	{

	}