void OnButtonPressed(object sender, ButtonXRTriggerEvent e) { DebugPrint(GetCurrentMethod()); if (_Enabled) { _Active = !_Active; if (_Active) { _Base.GetComponent <Renderer>().material.SetColor("_Color", _ColorActive); _Base.GetComponent <Renderer>().material.SetColor("_EmissionColor", new Color(_ButtonPressEmissionStrengthRed, _ButtonPressEmissionStrengthGreen, _ButtonPressEmissionStrengthBlue)); _Text.color = new Color(0f, 0.6f, 0f);// Color.green; _Text.GetComponent <Renderer>().material.SetColor("_GlowColor", new Color(0f, 1f, 0f)); } else { _Base.GetComponent <Renderer>().material.SetColor("_Color", _ColorInactive); _Base.GetComponent <Renderer>().material.SetColor("_EmissionColor", new Color(_ButtonPressEmissionStrengthGreen, _ButtonPressEmissionStrengthGreen, _ButtonPressEmissionStrengthGreen)); _Text.color = new Color(0.5f, 0.5f, 0.5f);// Color.white; _Text.GetComponent <Renderer>().material.SetColor("_GlowColor", new Color(1f, 1f, 1f)); } OnToggleEvent?.Invoke(this, new ButtonToggleEvent(this.name, _Active)); } }
private void HookToKeyboardEvents() { Task.Run(() => { api.CreateKeyboardHook((character) => { if (character.KeyCode == (KeyCode)Settings.KeyCodeToggle) { Logger.LogInfo($"Captured Toggle!"); OnToggleEvent?.Invoke(this, null); } if (character.KeyCode == (KeyCode)Settings.KeyCodeExit) { Logger.LogInfo($"Quiting.."); OnExitEvent?.Invoke(this, null); System.Windows.Forms.Application.Exit(); } }); System.Windows.Forms.Application.Run(); }); }
private void TriggerOnToggle(bool isOn) => _onToggleEvent?.Invoke(isOn);