コード例 #1
0
            public string GetDisplay(UI_Keyboard.KeyMode mode)
            {
                var mapping = keyMappings.FirstOrDefault(m => m.mode == mode);

                if (mapping == null)
                {
                    return("□");
                }
                else
                {
                    return(string.IsNullOrEmpty(mapping.display) ? mapping.value : mapping.display);
                }
            }
コード例 #2
0
        public void UpdateMode(UI_Keyboard.KeyMode mode)
        {
            if (keyMap.HasMapping(mode))
            {
                this.mode = mode;

                if (!keytext)
                {
                    keytext = GetComponentInChildren <Text>();
                }

                if (keytext)
                {
                    keytext.text = keyMap.GetDisplay(mode);
                }
                else
                {
                    Debug.LogError(this.name + " [Key Text component missing]");
                }
            }
        }
コード例 #3
0
            public string this[UI_Keyboard.KeyMode mode]
            {
                get
                {
                    var mapping = keyMappings.FirstOrDefault(m => m.mode == mode);

                    return(mapping != null ? mapping.value : string.Empty);
                }
                set
                {
                    var mapping = keyMappings.FirstOrDefault(m => m.mode == mode);

                    if (mapping != null)
                    {
                        mapping.value = value;
                    }
                    else
                    {
                        keyMappings.Add(new KeyMapping(mode, value));
                    }
                }
            }
コード例 #4
0
 public bool HasMapping(UI_Keyboard.KeyMode mode)
 {
     return(keyMappings.Any(m => m.mode == mode));
 }
コード例 #5
0
 public KeyMapping(UI_Keyboard.KeyMode mode, string value, string display = "")
 {
     this.mode    = mode;
     this.value   = value;
     this.display = display;
 }