Skip to content

Commit b0eb6a1

Browse files
cleaned up USBListener a bit
1 parent d4a4c75 commit b0eb6a1

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

Assets/MixedRealityToolkit/_Core/Utilities/Editor/USB/USBDeviceListener.cs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,19 @@
44
using System.Collections.Generic;
55
using UnityEditor;
66
using UnityEditor.Hardware;
7-
using UnityEngine;
87

98
namespace Microsoft.MixedReality.Toolkit.Core.Utilities.Editor.Usb
109
{
1110
[InitializeOnLoad]
1211
public class USBDeviceListener
1312
{
14-
[SerializeField]
1513
public static USBDeviceInfo[] USBDevices;
1614

1715
public delegate void OnUsbDevicesChanged(UsbDevice[] usbDevices);
1816

1917
public static event OnUsbDevicesChanged UsbDevicesChanged;
2018

21-
private static List<USBDeviceInfo> usbDevicesList = new List<USBDeviceInfo>(0);
19+
private static readonly List<USBDeviceInfo> USBDevicesList = new List<USBDeviceInfo>(0);
2220

2321
static USBDeviceListener()
2422
{
@@ -27,19 +25,16 @@ static USBDeviceListener()
2725

2826
private static void NotifyUsbDevicesChanged(UsbDevice[] devices)
2927
{
30-
if (UsbDevicesChanged != null)
31-
{
32-
UsbDevicesChanged.Invoke(devices);
33-
}
28+
UsbDevicesChanged?.Invoke(devices);
3429

35-
usbDevicesList.Clear();
30+
USBDevicesList.Clear();
3631

3732
foreach (UsbDevice device in devices)
3833
{
39-
usbDevicesList.Add(new USBDeviceInfo(device.vendorId, device.udid, device.productId, device.name, device.revision));
34+
USBDevicesList.Add(new USBDeviceInfo(device.vendorId, device.udid, device.productId, device.name, device.revision));
4035
}
4136

42-
USBDevices = usbDevicesList.ToArray();
37+
USBDevices = USBDevicesList.ToArray();
4338
}
4439
}
4540
}

0 commit comments

Comments
 (0)