From a8e6f3184296c5964f202dd2c5bcb5bda7a3b7c7 Mon Sep 17 00:00:00 2001 From: Andy Baker Date: Tue, 1 Oct 2024 14:36:09 +0100 Subject: [PATCH] Tweak the logic for brush size UI [CI BUILD] --- Assets/Scripts/GUI/BrushSettingsTray.cs | 27 ++++++++++++++----------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/Assets/Scripts/GUI/BrushSettingsTray.cs b/Assets/Scripts/GUI/BrushSettingsTray.cs index 01e4420da2..cfa00298a5 100644 --- a/Assets/Scripts/GUI/BrushSettingsTray.cs +++ b/Assets/Scripts/GUI/BrushSettingsTray.cs @@ -36,24 +36,26 @@ protected override void OnDestroy() private void ListenForConnectedDevices() { - List devices = new List(); - InputDevices.GetDevices(devices); - foreach (InputDevice device in devices) + bool needsBrushSizeUI = false; + InputDevice tryGetUnityXRController = InputDevices.GetDeviceAtXRNode(XRNode.LeftHand); + if (tryGetUnityXRController.isValid && tryGetUnityXRController.name.Contains("Logitech MX Ink")) { - DeviceConnected(device); + needsBrushSizeUI = true; + } + else + { + tryGetUnityXRController = InputDevices.GetDeviceAtXRNode(XRNode.RightHand); + if (tryGetUnityXRController.isValid && tryGetUnityXRController.name.Contains("Logitech MX Ink")) + { + needsBrushSizeUI = true; + } } - } - private void DeviceConnected(InputDevice device) - { - Debug.Log($"Device name: {device.name}"); - bool needsBrushSizeUi = device.name.StartsWith("Logitech MX Ink"); - if (needsBrushSizeUi) + if (needsBrushSizeUI) { DoAnimateIn(); + UpdateSliderToMatchCurrentSize(); } - - UpdateSliderToMatchCurrentSize(); } private void UpdateSliderToMatchCurrentSize() @@ -72,6 +74,7 @@ protected override void Start() protected override void OnToolChanged() { UpdateSliderToMatchCurrentSize(); + ListenForConnectedDevices(); } public void OnSliderChanged(Vector3 value)