Skip to content

Commit 3a067e9

Browse files
committed
Organized focusedObject so focusedObject does not change in the middle of an event, or before gestures are cancelled.
1 parent 52225b5 commit 3a067e9

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

Assets/HoloToolkit/Input/Scripts/GestureManager.cs

Lines changed: 7 additions & 6 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>
@@ -156,7 +156,7 @@ private void OnTap()
156156
{
157157
if (FocusedObject != null)
158158
{
159-
FocusedObject.SendMessage("OnSelect");
159+
FocusedObject.SendMessage("OnSelect", SendMessageOptions.DontRequireReceiver);
160160
}
161161
}
162162

@@ -204,23 +204,23 @@ private void OnManipulation(bool inProgress, Vector3 offset)
204204

205205
void LateUpdate()
206206
{
207-
GameObject oldFocusedObject = FocusedObject;
207+
GameObject newFocusedObject;
208208

209209
if (GazeManager.Instance.Hit &&
210210
OverrideFocusedObject == null &&
211211
GazeManager.Instance.HitInfo.collider != null)
212212
{
213213
// If gaze hits a hologram, set the focused object to that game object.
214214
// Also if the caller has not decided to override the focused object.
215-
FocusedObject = GazeManager.Instance.HitInfo.collider.gameObject;
215+
newFocusedObject = GazeManager.Instance.HitInfo.collider.gameObject;
216216
}
217217
else
218218
{
219219
// If our gaze doesn't hit a hologram, set the focused object to null or override focused object.
220-
FocusedObject = OverrideFocusedObject;
220+
newFocusedObject = OverrideFocusedObject;
221221
}
222222

223-
if (FocusedObject != oldFocusedObject)
223+
if (FocusedObject != newFocusedObject)
224224
{
225225
// If the currently focused object doesn't match the old focused object, cancel the current gesture.
226226
// Start looking for new gestures. This is to prevent applying gestures from one hologram to another.
@@ -234,6 +234,7 @@ void LateUpdate()
234234
OnTap();
235235
}
236236
#endif
237+
FocusedObject = newFocusedObject;
237238
}
238239

239240
void OnDestroy()

0 commit comments

Comments
 (0)