Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Issue with Changing DualShock 4 Lightbar Color in Unity

Discussion in 'Input System' started by EmerickGrimm, Sep 8, 2023.

  1. EmerickGrimm

    EmerickGrimm

    Joined:
    Mar 18, 2018
    Posts:
    6
    I've encountered an issue when trying to change the lightbar color of a DualShock 4 controller in my Unity project. I'm using the new Input System and attempted to change the color using DualShockGamepad.SetLightBarColor, but I'm having no success.

    Here's my code:

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.InputSystem;
    3. using UnityEngine.InputSystem.DualShock;
    4. public class DS4Controller : MonoBehaviour
    5. {
    6.     public void SetLightbar(Color requestedCollor)
    7.     {
    8.         var sonyGamepad = DualShockGamepad.current;
    9.         if (sonyGamepad != null)
    10.         {
    11.             sonyGamepad.SetLightBarColor(requestedCollor);
    12.             Debug.Log("Gamepad detected!" + " " + sonyGamepad);
    13.         }
    14.     }
    15.  
    16.     void Start()
    17.     {
    18.         SetLightbar(Color.red);
    19.  
    20.     }

    I have a connected DualShock 4 gamepad (BT, no DS4Windows), and I've confirmed that the code is executing. However, the lightbar color remains unchanged.

    I'm using Unity 2021.3.18f1 on win, and my project is set up to use the new Input System (1.4.4).

    Please, can you advise me on what might be the issue and how I can correctly change the DualShock 4 lightbar color? Perhaps I missed something in the settings or need to enable additional features?
     
  2. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    4,362
    You could update unity to the latest 2021 lts and update the input system (1.7 is already out). Might help
     
  3. EmerickGrimm

    EmerickGrimm

    Joined:
    Mar 18, 2018
    Posts:
    6
    Nope, still not working.