Skip to content

Commit 44e9e61

Browse files
committed
It makes no sense to hide the cursor when there is no cursor listed for a given state. It's better just retain the last one. Otherwise you are obliged to add a cursor for EVERY possible state.
1 parent 11f0e24 commit 44e9e61

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

Assets/HoloToolkit/Input/Scripts/Cursor/ObjectCursor.cs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,21 +51,19 @@ public override void OnCursorStateChange(CursorStateEnum state)
5151

5252
if (state != CursorStateEnum.Contextual)
5353
{
54-
// Hide all children first
55-
for(int i = 0; i < ParentTransform.childCount; i++)
54+
var newActive = CursorStateData.FirstOrDefault(p => p.CursorState == state);
55+
if (newActive.Name == null)
5656
{
57-
ParentTransform.GetChild(i).gameObject.SetActive(false);
57+
return;
5858
}
5959

60-
// Set active any that match the current state
61-
for (int i = 0; i < CursorStateData.Length; i++)
60+
var oldActive = CursorStateData.FirstOrDefault(p => p.CursorObject.activeSelf);
61+
if (oldActive.Name != null)
6262
{
63-
if (CursorStateData[i].CursorState == state)
64-
{
65-
CursorStateData[i].CursorObject.SetActive(true);
66-
}
63+
oldActive.CursorObject.SetActive(false);
6764
}
68-
}
65+
66+
newActive.CursorObject.SetActive(true);
6967
}
7068
}
7169
}

0 commit comments

Comments
 (0)