示例#1
0
    void Lightbar()
    {
        // Make the lightbar change colour when we hold down buttons
        if (Input.GetKey((KeyCode)Enum.Parse(typeof(KeyCode), "Joystick" + stickID + "Button0", true)))
        {
            lightbarColour = Color.Lerp(lightbarColour, Color.blue, Time.deltaTime * 4f);
        }

        if (Input.GetKey((KeyCode)Enum.Parse(typeof(KeyCode), "Joystick" + stickID + "Button1", true)))
        {
            lightbarColour = Color.Lerp(lightbarColour, Color.red, Time.deltaTime * 4f);
        }

        if (Input.GetKey((KeyCode)Enum.Parse(typeof(KeyCode), "Joystick" + stickID + "Button2", true)))
        {
            lightbarColour = Color.Lerp(lightbarColour, Color.magenta, Time.deltaTime * 4f);
        }

        if (Input.GetKey((KeyCode)Enum.Parse(typeof(KeyCode), "Joystick" + stickID + "Button3", true)))
        {
            lightbarColour = Color.Lerp(lightbarColour, Color.green, Time.deltaTime * 4f);
        }

        // Set the lightbar sprite and the physical lightbar change to the current colour
        gamePad.lightbar.color = lightbarColour;
        gamePad.light.color    = lightbarColour;
        PS4Input.PadSetLightBar(playerId,
                                Mathf.RoundToInt(lightbarColour.r * 255),
                                Mathf.RoundToInt(lightbarColour.g * 255),
                                Mathf.RoundToInt(lightbarColour.b * 255));
    }
示例#2
0
    public void SetLightColor(Color color)
    {
#if UNITY_PS4 && !(UNITY_EDITOR)
        PS4Input.PadSetLightBar(0,
                                Mathf.RoundToInt(color.r * 255),
                                Mathf.RoundToInt(color.g * 255),
                                Mathf.RoundToInt(color.b * 255));
#endif
    }