Skip to content

NullReferenceException when using PS5 controller #1

@Walter-Hulsebos

Description

@Walter-Hulsebos

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

  • Connect a PS5 controller to the device via USB-C.
  • Run the project.
  • Click Start.
  • Pres any key on the PS5 controller.
  • The exception will be thrown when the project tries to retrieve the texture for the controller.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions