Skip to content

Commit ae598be

Browse files
committed
Not using single-letter variables anymore and added comments, by request
1 parent fcd079f commit ae598be

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

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

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,32 +56,39 @@ public override void OnCursorStateChange(CursorStateEnum state)
5656
base.OnCursorStateChange(state);
5757
if (state != CursorStateEnum.Contextual)
5858
{
59+
60+
// First, try to find a cursor for the current state
5961
var newActive = new ObjectCursorDatum();
60-
for(int i = 0; i < CursorStateData.Length; i++)
62+
for(int cursorIndex = 0; cursorIndex < CursorStateData.Length; cursorIndex++)
6163
{
62-
ObjectCursorDatum c = CursorStateData[i];
63-
if (c.CursorState == state)
64+
ObjectCursorDatum cursor = CursorStateData[cursorIndex];
65+
if (cursor.CursorState == state)
6466
{
65-
newActive = c;
67+
newActive = cursor;
6668
break;
6769
}
6870
}
6971

72+
// If no cursor for current state is found, let the last active cursor be
73+
// (any cursor is better than an invisible cursor)
7074
if (newActive.Name == null)
7175
{
7276
return;
7377
}
7478

75-
for(int i = 0; i < CursorStateData.Length; i++)
79+
// If we come here, there is a cursor for the new state,
80+
// so de-activate a possible earlier active cursor
81+
for(int cursorIndex = 0; cursorIndex < CursorStateData.Length; cursorIndex++)
7682
{
77-
ObjectCursorDatum c = CursorStateData[i];
78-
if (c.CursorObject.activeSelf)
83+
ObjectCursorDatum cursor = CursorStateData[cursorIndex];
84+
if (cursor.CursorObject.activeSelf)
7985
{
80-
c.CursorObject.SetActive(false);
86+
cursor.CursorObject.SetActive(false);
8187
break;
8288
}
8389
}
8490

91+
// ... and set the cursor for the new state active.
8592
newActive.CursorObject.SetActive(true);
8693
}
8794
}

0 commit comments

Comments
 (0)