示例#1
0
 private void Update()
 {
     if (toggle != null && toggle.isOn)
     {
         if (keyList == null)
         {
             keyList = new List <string>();
             keybindSetter("");
             clickSkip = false;
             GadgetCoreAPI.FreezeInput("Keybinding");
         }
         toggle.graphic.color = new Color(toggle.graphic.color.r, toggle.graphic.color.g, toggle.graphic.color.b, Mathf.RoundToInt(Time.time * 8) % 2);
         foreach (KeyCode key in Enum.GetValues(typeof(KeyCode)))
         {
             if (key != KeyCode.Escape && Input.GetKeyDown(key))
             {
                 if (!allowMultiBind)
                 {
                     keyList = new List <string>();
                 }
                 keyList.Add(key.ToString());
                 keybindSetter(keyList.Aggregate(new StringBuilder(), (a, b) => { if (a.Length > 0)
                                                                                  {
                                                                                      a.Append('+');
                                                                                  }
                                                                                  a.Append(b); return(a); }).ToString());
             }
             else if (Input.GetKeyUp(key))
             {
                 if (!clickSkip && key == KeyCode.Mouse0)
                 {
                     clickSkip = true;
                     continue;
                 }
                 keyList     = null;
                 toggle.isOn = false;
                 GadgetCoreAPI.UnfreezeInput("Keybinding");
             }
         }
     }
 }