Skip to content

Commit 5d53b7d

Browse files
committed
Updated state behavior in BaseGrabbable
1 parent 0b549dc commit 5d53b7d

File tree

1 file changed

+14
-2
lines changed
  • Assets/HoloToolkit-Examples/MotionControllers-GrabMechanics/Scripts

1 file changed

+14
-2
lines changed

Assets/HoloToolkit-Examples/MotionControllers-GrabMechanics/Scripts/BaseGrabbable.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ protected virtual void StartGrab(BaseGrabber grabber)
158158

159159
// Attach ourselves to this grabber
160160
AttachToGrabber(grabber);
161-
161+
162162
if (OnGrabbed != null)
163163
OnGrabbed(this);
164164
}
@@ -221,7 +221,19 @@ protected virtual void OnGrabStay()
221221
/// </summary>
222222
protected Stack<BaseGrabber> activeGrabbers = new Stack<BaseGrabber>();
223223

224+
protected virtual void Update()
225+
{
226+
if (prevGrabState != GrabState && OnGrabStateChange != null)
227+
OnGrabStateChange(this);
228+
229+
if (prevContactState != ContactState && OnContactStateChange != null)
230+
OnContactStateChange(this);
231+
232+
prevGrabState = GrabState;
233+
prevContactState = ContactState;
234+
}
235+
224236
private GrabStateEnum prevGrabState = GrabStateEnum.Inactive;
225-
private GrabStateEnum prevHoverState = GrabStateEnum.Inactive;
237+
private GrabStateEnum prevContactState = GrabStateEnum.Inactive;
226238
}
227239
}

0 commit comments

Comments
 (0)