static private KeyEventField ( |
||
e | ||
Результат |
private void ShowKeys() { int controlID = GUIUtility.GetControlID(PreferencesWindow.s_KeysControlHash, FocusType.Keyboard); GUILayout.Space(10f); GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.BeginVertical(new GUILayoutOption[] { GUILayout.Width(185f) }); GUILayout.Label("Actions", PreferencesWindow.constants.settingsBoxTitle, new GUILayoutOption[] { GUILayout.ExpandWidth(true) }); this.m_KeyScrollPos = GUILayout.BeginScrollView(this.m_KeyScrollPos, PreferencesWindow.constants.settingsBox); PrefKey prefKey = null; PrefKey prefKey2 = null; bool flag = false; foreach (KeyValuePair <string, PrefKey> current in Settings.Prefs <PrefKey>()) { if (!flag) { if (current.Value == this.m_SelectedKey) { flag = true; } else { prefKey = current.Value; } } else { if (prefKey2 == null) { prefKey2 = current.Value; } } EditorGUI.BeginChangeCheck(); if (GUILayout.Toggle(current.Value == this.m_SelectedKey, current.Key, PreferencesWindow.constants.keysElement, new GUILayoutOption[0])) { this.m_SelectedKey = current.Value; } if (EditorGUI.EndChangeCheck()) { GUIUtility.keyboardControl = controlID; } } GUILayout.EndScrollView(); GUILayout.EndVertical(); GUILayout.Space(10f); GUILayout.BeginVertical(new GUILayoutOption[0]); if (this.m_SelectedKey != null) { Event @event = this.m_SelectedKey.KeyboardEvent; GUI.changed = false; string[] array = this.m_SelectedKey.Name.Split(new char[] { '/' }); GUILayout.Label(array[0], "boldLabel", new GUILayoutOption[0]); GUILayout.Label(array[1], "boldLabel", new GUILayoutOption[0]); GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.Label("Key:", new GUILayoutOption[0]); @event = EditorGUILayout.KeyEventField(@event, new GUILayoutOption[0]); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.Label("Modifiers:", new GUILayoutOption[0]); GUILayout.BeginVertical(new GUILayoutOption[0]); if (Application.platform == RuntimePlatform.OSXEditor) { @event.command = GUILayout.Toggle(@event.command, "Command", new GUILayoutOption[0]); } @event.control = GUILayout.Toggle(@event.control, "Control", new GUILayoutOption[0]); @event.shift = GUILayout.Toggle(@event.shift, "Shift", new GUILayoutOption[0]); @event.alt = GUILayout.Toggle(@event.alt, "Alt", new GUILayoutOption[0]); GUILayout.EndVertical(); GUILayout.EndHorizontal(); if (GUI.changed) { this.m_SelectedKey.KeyboardEvent = @event; Settings.Set <PrefKey>(this.m_SelectedKey.Name, this.m_SelectedKey); } else { if (GUIUtility.keyboardControl == controlID && Event.current.type == EventType.KeyDown) { KeyCode keyCode = Event.current.keyCode; if (keyCode != KeyCode.UpArrow) { if (keyCode == KeyCode.DownArrow) { if (prefKey2 != null) { this.m_SelectedKey = prefKey2; } Event.current.Use(); } } else { if (prefKey != null) { this.m_SelectedKey = prefKey; } Event.current.Use(); } } } } GUILayout.EndVertical(); GUILayout.Space(10f); GUILayout.EndHorizontal(); GUILayout.Space(5f); if (GUILayout.Button("Use Defaults", new GUILayoutOption[] { GUILayout.Width(120f) })) { this.RevertKeys(); } }