TheHotPathShow / Episode-11

0 stars 0 forks source link

NullReferenceException when using PS5 controller #1

Open Walter-Hulsebos opened 2 months ago

Walter-Hulsebos commented 2 months ago

Issue Description

When using the project with a PS5 controller (device name: HID:Wireless Controller), a NullReferenceException occurs at the following line in UIHook.cs (EnterGameMenuSystem.OnUpdate):

actionElement.Q<VisualElement>("Icon").style.backgroundImage = texturesForController.GetFromActionAndDevice(action, device);

Steps to Reproduce

Expected Behavior

The project should handle the PS5 controller correctly and not throw any exceptions when retrieving the texture for the controller actions.

Additional Information

The issue seems to be related to the UIHook.Instance.GetSchemeTextureCollectionFromName($"{device.description.interfaceName}:{device.description.product}); function, which returns null when the PS5 controller is used. Environment

Unity version: 2022.3.26f1 Controller: PS5 Controller connected via USB-C Cable (device name: HID:Wireless Controller)

Possible Solution

Go to the UI Hook Component in the PlayGround and add a new entry in the ControllerNameAndTexturePairs array, linking to the PS5 controller's Texture Collection with HID:Wireless Controller not just HID:DualSense Wireless Controller

image

Walter-Hulsebos commented 2 months ago

Ideally I'd have a generic Gamepad as a fallback if possible. I could try cooking up a PR if you'd like.