diff --git a/Assets/SteamVR/InteractionSystem/Core/Scripts/CircularDrive.cs b/Assets/SteamVR/InteractionSystem/Core/Scripts/CircularDrive.cs index 2d11f67d..b139d4ba 100644 --- a/Assets/SteamVR/InteractionSystem/Core/Scripts/CircularDrive.cs +++ b/Assets/SteamVR/InteractionSystem/Core/Scripts/CircularDrive.cs @@ -73,7 +73,22 @@ public enum Axis_t public TextMesh debugText = null; [Tooltip( "The output angle value of the drive in degrees, unlimited will increase or decrease without bound, take the 360 modulus to find number of rotations" )] - public float outAngle; + [SerializeField] + private float outAngle; + + public float OutAngle + { + get + { + return outAngle; + } + set + { + outAngle = value; + UpdateAll(); + } + } + private Quaternion start; @@ -93,7 +108,7 @@ public enum Axis_t private bool driving = false; - // If the drive is limited as is at min/max, angles greater than this are ignored + // If the drive is limited as is at min/max, angles greater than this are ignored private float minMaxAngularThreshold = 1.0f; private bool frozen = false; @@ -243,11 +258,9 @@ private void OnHandHoverEnd( Hand hand ) private void HandHoverUpdate( Hand hand ) { GrabTypes startingGrabType = hand.GetGrabStarting(); - bool isGrabEnding = hand.IsGrabbingWithType(grabbedWithType) == false; - if (grabbedWithType == GrabTypes.None && startingGrabType != GrabTypes.None) + if (interactable.attachedToHand == null && startingGrabType != GrabTypes.None) { - grabbedWithType = startingGrabType; // Trigger was just pressed lastHandProjected = ComputeToTransformProjected( hand.hoverSphereTransform ); @@ -259,30 +272,28 @@ private void HandHoverUpdate( Hand hand ) driving = true; - ComputeAngle( hand ); - UpdateAll(); - + hand.AttachObject(gameObject, startingGrabType, attachmentFlags); hand.HideGrabHint(); - } - else if (grabbedWithType != GrabTypes.None && isGrabEnding) - { - // Trigger was just released - if ( hoverLock ) - { - hand.HoverUnlock(interactable); - handHoverLocked = null; - } + } + } - driving = false; - grabbedWithType = GrabTypes.None; + protected virtual void HandAttachedUpdate(Hand hand) + { + ComputeAngle(hand); + UpdateAll(); + + if (hand.IsGrabEnding(this.gameObject)) + { + hand.DetachObject(gameObject); + + if (hoverLock) + { + hand.HoverUnlock(interactable); + handHoverLocked = null; + } } + } - if ( driving && isGrabEnding == false && hand.hoveringInteractable == this.interactable ) - { - ComputeAngle( hand ); - UpdateAll(); - } - } //-------------------------------------------------