Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug/fix pinch and grab detection event subscription and grab detection logic #1686

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Packages/Tracking/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed some warnings around runtime variables that were only used in editor mode
- Fixed an issue with Physical Hands and Unity 6 due to the physics Contact Generation setting being removed
- (UI Input Preview) Added explicit missing dependancy on the "Unity UI" package
- Clients were not able to subscribe to the events on the PinchDetector and GrabDetector scripts as the properties were exposed as readonly.
- GrabDetector detection logic was inverted, so open hands were interpreted as grabs. Now fixed.

### Changed
- Updated all custom shaders to support the Universal Render Pipeline concurrently with the Built-in Render Pipeline
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,26 @@ public class GrabDetector : ActionDetector
public bool IsGrabbing => IsDoingAction;

// Accessor actions for readability
public Action<Hand> OnGrabStart => onActionStart;
public Action<Hand> OnGrabEnd => onActionEnd;
public Action<Hand> OnGrabbing => onAction;
public Action<Hand> OnGrabStart
{
get => onActionStart;

set => onActionStart = value;
}

public Action<Hand> OnGrabEnd
{
get => onActionEnd;

set => onActionEnd = value;
}

public Action<Hand> OnGrabbing
{
get => onAction;

set => onAction = value;
}

/// <summary>
/// Updates the grab status based on the hand data.
Expand All @@ -50,7 +67,8 @@ protected override void UpdateActionStatus(Hand _hand)
}

float _grabStrength = _hand.GrabStrength;
if (_grabStrength < activateStrength)

if (_grabStrength > activateStrength)
{
if (!IsDoingAction)
{
Expand All @@ -64,7 +82,7 @@ protected override void UpdateActionStatus(Hand _hand)

IsDoingAction = true;
}
else if (_grabStrength > deactivateStrength)
else if (_grabStrength < deactivateStrength)
{
if (IsDoingAction)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,27 @@ public enum PinchableFingerType
public bool IsPinching => IsDoingAction;

// Accessor actions for readability
public Action<Hand> OnPinchStart => onActionStart;
public Action<Hand> OnPinchEnd => onActionEnd;
public Action<Hand> OnPinching => onAction;
public Action<Hand> OnPinchStart
{
get => onActionStart;

set => onActionStart = value;
}

public Action<Hand> OnPinchEnd
{
get => onActionEnd;

set => onActionEnd = value;

}

public Action<Hand> OnPinching
{
get => onAction;

set => onAction = value;
}

/// <summary>
/// Updates the pinch status based on the hand data.
Expand Down