// Update a key's color based on the user's health void UpdateKeyOnHealth(KeyCode kb, int thresh) { // If we reached the given threshold, set the color of the given key to the health color if (health >= thresh) { Led.SetLightingForKeyWithKeyName(kb, (int)healthCol.r, (int)healthCol.g, (int)healthCol.b); } // Else, set it to black else { Led.SetLightingForKeyWithKeyName(kb, 0, 0, 0); } }
// Start is called before the first frame update void Start() { // Initialize and set target device Led.Init("UniG Demo App"); Led.SetTargetDevice((int)Led.DeviceLightingType.All); // Highlight the WASD keys Led.SetLightingForKeyWithKeyName(KeyCode.W, 100, 100, 100); Led.SetLightingForKeyWithKeyName(KeyCode.A, 100, 100, 100); Led.SetLightingForKeyWithKeyName(KeyCode.S, 100, 100, 100); Led.SetLightingForKeyWithKeyName(KeyCode.D, 100, 100, 100); // Get the health colors healthGood = GetColor("Lives/Good", Led.UnityToPercentage(Color.green)); healthMid = GetColor("Lives/Medium", new Color(100, 50, 0)); healthCrit = GetColor("Lives/Bad", Led.UnityToPercentage(Color.red)); // Set initialized to true initialized = true; }