/// <summary> /// Renders a key bind option. /// </summary> private static void RenderKeyBind(string name, KeyCode currentBinding, Action <KeyCode> acceptClicked) { GUILayout.BeginHorizontal(); GUILayout.Label(name); if (GUILayout.Button(currentBinding.ToString(), HighLogic.Skin.button, GUILayout.Width(100.0f))) { KeyBindPopup.Show(name, currentBinding, acceptClicked); } GUILayout.EndHorizontal(); }
/// <summary> /// Shows a key bind popup allowing the user to select a key for binding. /// </summary> public static void Show(string name, KeyCode currentBinding, Action <KeyCode> acceptClicked) { if (instance == null) { instance = new GameObject("SelectKeyBind").AddComponent <KeyBindPopup>(); } instance.Name = name; instance.Binding = currentBinding; instance.AcceptClicked = acceptClicked; }
/// <summary> /// Called by unity when the component is created. /// </summary> protected virtual void Awake() { if (instance == null) { instance = this; } else if (instance != this) { OnCancel(); } }
/// <summary> /// Shows a key bind popup allowing the user to select a key for binding. /// </summary> public static void Show(string name, KeyCode currentBinding, Action<KeyCode> acceptClicked) { if (instance == null) { instance = new GameObject("SelectKeyBind").AddComponent<KeyBindPopup>(); } instance.Name = name; instance.Binding = currentBinding; instance.AcceptClicked = acceptClicked; }