Skip to content

Commit ee53a60

Browse files
committed
Removed usage of Linq, used explicit for loops.
1 parent dfb79ee commit ee53a60

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

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

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Licensed under the MIT License. See LICENSE in the project root for license information.
33

44
using System;
5-
using System.Linq;
65
using UnityEngine;
76

87
namespace HoloToolkit.Unity.InputModule
@@ -34,7 +33,7 @@ public struct ObjectCursorDatum
3433
/// </summary>
3534
protected override void OnEnable()
3635
{
37-
if (ParentTransform == null)
36+
if(ParentTransform == null)
3837
{
3938
ParentTransform = transform;
4039
}
@@ -51,16 +50,30 @@ public override void OnCursorStateChange(CursorStateEnum state)
5150
base.OnCursorStateChange(state);
5251
if (state != CursorStateEnum.Contextual)
5352
{
54-
ObjectCursorDatum newActive = CursorStateData.FirstOrDefault(p => p.CursorState == state);
53+
var newActive = new ObjectCursorDatum();
54+
for(int i = 0; i < CursorStateData.Length; i++)
55+
{
56+
ObjectCursorDatum c = CursorStateData[i];
57+
if (c.CursorState == state)
58+
{
59+
newActive = c;
60+
break;
61+
}
62+
}
63+
5564
if (newActive.Name == null)
5665
{
5766
return;
5867
}
5968

60-
ObjectCursorDatum oldActive = CursorStateData.FirstOrDefault(p => p.CursorObject.activeSelf);
61-
if (oldActive.Name != null)
69+
for(int i = 0; i < CursorStateData.Length; i++)
6270
{
63-
oldActive.CursorObject.SetActive(false);
71+
ObjectCursorDatum c = CursorStateData[i];
72+
if (c.CursorObject.activeSelf)
73+
{
74+
c.CursorObject.SetActive(false);
75+
break;
76+
}
6477
}
6578

6679
newActive.CursorObject.SetActive(true);

0 commit comments

Comments
 (0)