using System; using UnityEngine; using UnityEngine.UI; namespace vamtaco { public class UIButtonKeyboardShortcut : MVRScript { private const string PluginName = "UIButton KB Shortcut"; private bool _logErrors = true; private bool _logMessages = false; private Button _button; JSONStorableStringChooser KeyboardStringChooser; public override void Init() { try { LogMessage("Initializing..."); this.KeyboardStringChooser = new JSONStorableStringChooser(nameof(KeyboardStringChooser), Enum.GetNames(typeof(KeyCode)).ToList(), "Space", "Shortcut Key:"); RegisterStringChooser(KeyboardStringChooser); CreateScrollablePopup(KeyboardStringChooser); var trigger = this.containingAtom.GetStorableByID("Trigger"); UIButtonTrigger t = trigger.GetComponent(); _button = t.button; //You can also get it this way, not sure which would be more efficient. //_button = this.containingAtom.GetComponentInChildren