示例#1
0
        private static void AddProcessors(InputControl control, ref InputControlLayout.ControlItem controlItem, string layoutName)
        {
            var processorCount = controlItem.processors.Count;

            for (var n = 0; n < processorCount; ++n)
            {
                var name = controlItem.processors[n].name;
                var type = InputProcessor.s_Processors.LookupTypeRegistration(name);
                if (type == null)
                {
                    throw new InvalidOperationException(
                              $"Cannot find processor '{name}' referenced by control '{controlItem.name}' in layout '{layoutName}'");
                }

                var processor = Activator.CreateInstance(type);

                var parameters = controlItem.processors[n].parameters;
                if (parameters.Count > 0)
                {
                    NamedValue.ApplyAllToObject(processor, parameters);
                }

                control.AddProcessor(processor);
            }
        }