public void LoadMappings()
        {
            // basically have a circular reference here. The CreateControlBindings needs the actions to be registered and the register action for the axis needs the bindings in place. not really sure how this worked before
            _controlBindings = _scheme.CreateControlBindings();

            var actions = GetComponentsInChildren <IRegisteredAction>();

            foreach (var action in actions)
            {
                action.RegisterAction(this);
            }


            foreach (var binding in _controlBindings)
            {
                if (binding.Value.key.HasValue)
                {
                    MapDisplay(binding.Key, binding.Value.key.Value);
                }
                else
                {
                    MapDisplay(binding.Key, binding.Value.axis);
                }
            }
        }
Exemple #2
0
 private void Start()
 {
     _activeMappings = InputEx.IsControllerConnected() ? controllerMappings : kbMappings;
     if (_activeMappings.CreateControlBindings().TryGetValue(action, out var binding))
     {
         _binding = binding;
     }
     UpdateText();
 }
Exemple #3
0
        private void Update()
        {
            bool updateNeeded = false;

            var mappings = InputEx.IsControllerConnected() ? controllerMappings : kbMappings;

            if (_activeMappings.CreateControlBindings().TryGetValue(action, out var binding))
            {
                updateNeeded = _binding.HasValue && !Equals(_binding.Value, binding);
                _binding     = binding;
            }

            if (mappings != _activeMappings)
            {
                _activeMappings = mappings;
                updateNeeded    = true;
            }

            if (updateNeeded)
            {
                UpdateText();
            }
        }