Пример #1
0
        /// <summary>
        /// For the input <paramref name="InputID"/>. Returns the first <see cref="InputControl"/> recovered from <see cref="InputConfigurationInherentData"/>.
        /// Check is done in this order :
        ///     * <see cref="InputConfigurationInherentData.AttributedKeys"/>
        ///     * <see cref="InputConfigurationInherentData.AttributedMouseButtons"/>
        /// </summary>
        public static InputControl FindTheFirstInputControlForInputID(InputID InputID)
        {
            var InputConfigurationInherentData = InputConfigurationGameObject.Get().InputConfiguration.ConfigurationInherentData[InputID];

            if (InputConfigurationInherentData != null)
            {
                var inputControlLookup = InputControlLookup.Get();
                if (InputConfigurationInherentData.AttributedKeys != null)
                {
                    foreach (var attributedKey in InputConfigurationInherentData.AttributedKeys)
                    {
                        var inputControl = inputControlLookup.keyToKeyControlLookup[attributedKey];
                        if (inputControl != null)
                        {
                            return(inputControl);
                        }
                    }
                }

                if (InputConfigurationInherentData.AttributedMouseButtons != null)
                {
                    foreach (var attributedMouseButton in InputConfigurationInherentData.AttributedMouseButtons)
                    {
                        var inputControl = inputControlLookup.mouseButtonControlLookup[attributedMouseButton];
                        if (inputControl != null)
                        {
                            return(inputControl);
                        }
                    }
                }
            }

            return(null);
        }
Пример #2
0
        public static InputConfigurationGameObject Get()
        {
            if (Instance == null)
            {
                Instance = FindObjectOfType <InputConfigurationGameObject>();
            }

            return(Instance);
        }