Inheritance: IPrefType
Beispiel #1
0
        public PrefKey(string name, string shortcut)
        {
            this.m_name            = name;
            this.m_event           = Event.KeyboardEvent(shortcut);
            this.m_DefaultShortcut = shortcut;
            PrefKey prefKey = Settings.Get <PrefKey>(name, this);

            this.m_name  = prefKey.Name;
            this.m_event = prefKey.KeyboardEvent;
        }
Beispiel #2
0
 public void Load()
 {
     if (!this.m_Loaded)
     {
         this.m_Loaded = true;
         this.m_event  = Event.KeyboardEvent(this.m_Shortcut);
         PrefKey key = Settings.Get <PrefKey>(this.m_name, this);
         this.m_name  = key.Name;
         this.m_event = key.KeyboardEvent;
     }
 }
Beispiel #3
0
        public void Load()
        {
            if (this.m_Loaded)
            {
                return;
            }
            this.m_Loaded = true;
            this.m_event  = Event.KeyboardEvent(this.m_Shortcut);
            PrefKey prefKey = Settings.Get <PrefKey>(this.m_name, this);

            this.m_name  = prefKey.Name;
            this.m_event = prefKey.KeyboardEvent;
        }
Beispiel #4
0
        public void Load()
        {
            if (m_Loaded)
            {
                return;
            }

            m_Loaded = true;

            this.m_event = Event.KeyboardEvent(m_Shortcut);
            PrefKey pk = Settings.Get(m_name, this);

            this.m_name  = pk.Name;
            this.m_event = pk.KeyboardEvent;
        }
        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();
            }
        }