Esempio n. 1
0
        public string KeyToString(KeyCode code)
        {
            switch (code)
            {
            case KeyCode.Backslash:
                return("\\");

            case KeyCode.Quote:
                return("\"");

            default:
                return(KeyCodeConverter.KeyToString(code));
            }
        }
Esempio n. 2
0
        public static void Main(string[] args)
        {
            InputConverter converter                          = new InputConverter();
            string         convertSourceFile                  = "InputManager.asset";
            string         convertDestinationFile             = "InputManager.xml";
            string         defaultInputManagerDestinationFile = "InputManager_Generated.asset";
            string         keyConverterFile                   = "KeyCodeConverter.cs";
            string         keyConverterTemplate               = File.ReadAllText("key_code_converter_template.txt");

            converter.ConvertUnityInputManager(convertSourceFile, convertDestinationFile);
            converter.GenerateDefaultUnityInputManager(defaultInputManagerDestinationFile);
            KeyNameGenerator.GenerateKeyNames(keyConverterTemplate, keyConverterFile);

            Console.WriteLine("Your key is: {0}", KeyCodeConverter.KeyToString(KeyCode.Joystick1Button11));
        }
Esempio n. 3
0
        public KeyCode OnGUI(Rect position, string label, KeyCode key)
        {
            GUI.SetNextControlName(m_controlName);
            bool hasFocus = (GUI.GetNameOfFocusedControl() == m_controlName);

            if (!m_isEditing && hasFocus)
            {
                m_keyString = key == KeyCode.None ? "" : KeyCodeConverter.KeyToString(key);
            }

            m_isEditing = hasFocus;
            if (m_isEditing)
            {
                m_keyString = EditorGUI.TextField(position, label, m_keyString);
            }
            else
            {
                EditorGUI.TextField(position, label, key == KeyCode.None ? "" : KeyCodeConverter.KeyToString(key));
            }

            if (m_isEditing && Event.current.type == EventType.KeyUp)
            {
                key = KeyCodeConverter.StringToKey(m_keyString);
                if (key == KeyCode.None)
                {
                    m_keyString = "";
                }
                else
                {
                    m_keyString = KeyCodeConverter.KeyToString(key);
                }
                m_isEditing = false;
            }

            return(key);
        }
 string Key2String(KeyCode key)
 {
     return key == KeyCode.None ? "" : KeyCodeConverter.KeyToString(key);
 }