Skip to content

Commit

Permalink
Tweak the logic for brush size UI
Browse files Browse the repository at this point in the history
[CI BUILD]
  • Loading branch information
andybak committed Oct 1, 2024
1 parent c4a1df4 commit a8e6f31
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions Assets/Scripts/GUI/BrushSettingsTray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,26 @@ protected override void OnDestroy()

private void ListenForConnectedDevices()
{
List<InputDevice> devices = new List<InputDevice>();
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()
Expand All @@ -72,6 +74,7 @@ protected override void Start()
protected override void OnToolChanged()
{
UpdateSliderToMatchCurrentSize();
ListenForConnectedDevices();
}

public void OnSliderChanged(Vector3 value)
Expand Down

0 comments on commit a8e6f31

Please sign in to comment.