Skip to content

Commit ea24458

Browse files
Stephen HodgsonStephen Hodgson
authored andcommitted
Added delegate event to HandsManager.cs for better hand tracking capabilities.
1 parent 6add245 commit ea24458

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

Assets/HoloToolkit/Input/Scripts/HandsManager.cs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,16 @@ public bool HandDetected
2020
get { return trackedHands.Count > 0; }
2121
}
2222

23+
/// <summary>
24+
/// Occurs when users hand is detected or lost.
25+
/// </summary>
26+
/// <param name="handDetected">True if a hand is Detected, else false.</param>
27+
public delegate void HandInViewDelegate(bool handDetected);
28+
public event HandInViewDelegate HandInView;
29+
2330
private HashSet<uint> trackedHands = new HashSet<uint>();
2431

25-
void Awake()
32+
private void Awake()
2633
{
2734
InteractionManager.SourceDetected += InteractionManager_SourceDetected;
2835
InteractionManager.SourceLost += InteractionManager_SourceLost;
@@ -37,6 +44,11 @@ private void InteractionManager_SourceDetected(InteractionSourceState state)
3744
}
3845

3946
trackedHands.Add(state.source.id);
47+
48+
if (HandInView != null)
49+
{
50+
HandInView(HandDetected);
51+
}
4052
}
4153

4254
private void InteractionManager_SourceLost(InteractionSourceState state)
@@ -50,10 +62,15 @@ private void InteractionManager_SourceLost(InteractionSourceState state)
5062
if (trackedHands.Contains(state.source.id))
5163
{
5264
trackedHands.Remove(state.source.id);
65+
66+
if (HandInView != null)
67+
{
68+
HandInView(HandDetected);
69+
}
5370
}
5471
}
5572

56-
void OnDestroy()
73+
private void OnDestroy()
5774
{
5875
InteractionManager.SourceDetected -= InteractionManager_SourceDetected;
5976
InteractionManager.SourceLost -= InteractionManager_SourceLost;

0 commit comments

Comments
 (0)