コード例 #1
0
 // Token: 0x06000238 RID: 568 RVA: 0x00018864 File Offset: 0x00016A64
 public static bool GetKeyCode(string text, out KeyCode key, out UIKeyBinding.Modifier modifier)
 {
     key      = KeyCode.None;
     modifier = UIKeyBinding.Modifier.None;
     if (string.IsNullOrEmpty(text))
     {
         return(true);
     }
     if (text.Length > 2 && text.Contains("+") && text[text.Length - 1] != '+')
     {
         string[] array = text.Split(new char[]
         {
             '+'
         }, 2);
         key = NGUITools.CaptionToKey(array[1]);
         try
         {
             modifier = (UIKeyBinding.Modifier)Enum.Parse(typeof(UIKeyBinding.Modifier), array[0]);
             return(true);
         }
         catch (Exception)
         {
             return(false);
         }
     }
     modifier = UIKeyBinding.Modifier.None;
     key      = NGUITools.CaptionToKey(text);
     return(true);
 }
コード例 #2
0
    /// <summary>
    /// Given the ToString() text, parse it for key and modifier information.
    /// </summary>

    static public bool GetKeyCode(string text, out KeyCode key, out Modifier modifier)
    {
        key      = KeyCode.None;
        modifier = Modifier.None;
        if (string.IsNullOrEmpty(text))
        {
            return(true);
        }

        if (text.Length > 2 && text.Contains("+") && text[text.Length - 1] != '+')
        {
            var parts = text.Split(new char[] { '+' }, 2);
            key = NGUITools.CaptionToKey(parts[1]);
            try { modifier = (Modifier)System.Enum.Parse(typeof(Modifier), parts[0]); }
            catch (System.Exception) { return(false); }
        }
        else
        {
            modifier = Modifier.None;
            key      = NGUITools.CaptionToKey(text);
        }
        return(true);
    }