Skip to content

Commit cb2393b

Browse files
authored
Merge pull request #222 from killerantz/FocusObjectFix
Focus object fix
2 parents 135224a + f1cf6d7 commit cb2393b

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

Assets/HoloToolkit/Input/Scripts/GestureManager.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public partial class GestureManager : Singleton<GestureManager>
4848
/// If its null, then the gazed at object will be selected.
4949
/// </summary>
5050
public GameObject OverrideFocusedObject { get; set; }
51-
51+
5252
/// <summary>
5353
/// Gets the currently focused object, or null if none.
5454
/// </summary>
@@ -116,9 +116,7 @@ void Start()
116116
gestureRecognizer.StartCapturingGestures();
117117
manipulationRecognizer.StartCapturingGestures();
118118
}
119-
120-
121-
119+
122120
private void InteractionManager_SourcePressed(InteractionSourceState state)
123121
{
124122
if (!HandPressed)
@@ -156,7 +154,7 @@ private void OnTap()
156154
{
157155
if (FocusedObject != null)
158156
{
159-
FocusedObject.SendMessage("OnSelect");
157+
FocusedObject.SendMessage("OnSelect", SendMessageOptions.DontRequireReceiver);
160158
}
161159
}
162160

@@ -204,27 +202,28 @@ private void OnManipulation(bool inProgress, Vector3 offset)
204202

205203
void LateUpdate()
206204
{
207-
GameObject oldFocusedObject = FocusedObject;
205+
GameObject newFocusedObject;
208206

209207
if (GazeManager.Instance.Hit &&
210208
OverrideFocusedObject == null &&
211209
GazeManager.Instance.HitInfo.collider != null)
212210
{
213211
// If gaze hits a hologram, set the focused object to that game object.
214212
// Also if the caller has not decided to override the focused object.
215-
FocusedObject = GazeManager.Instance.HitInfo.collider.gameObject;
213+
newFocusedObject = GazeManager.Instance.HitInfo.collider.gameObject;
216214
}
217215
else
218216
{
219217
// If our gaze doesn't hit a hologram, set the focused object to null or override focused object.
220-
FocusedObject = OverrideFocusedObject;
218+
newFocusedObject = OverrideFocusedObject;
221219
}
222220

223-
if (FocusedObject != oldFocusedObject)
221+
if (FocusedObject != newFocusedObject)
224222
{
225223
// If the currently focused object doesn't match the old focused object, cancel the current gesture.
226224
// Start looking for new gestures. This is to prevent applying gestures from one hologram to another.
227225
gestureRecognizer.CancelGestures();
226+
FocusedObject = newFocusedObject;
228227
gestureRecognizer.StartCapturingGestures();
229228
}
230229

0 commit comments

Comments
 (0)