public void SetData(int playerId, ControlMapper.InputBehaviorSettings[] data) { if (!base.initialized) { return; } this.playerId = playerId; for (int i = 0; i < data.Length; i++) { ControlMapper.InputBehaviorSettings inputBehaviorSettings = data[i]; if (inputBehaviorSettings != null && inputBehaviorSettings.isValid) { InputBehavior inputBehavior = this.GetInputBehavior(inputBehaviorSettings.inputBehaviorId); if (inputBehavior != null) { UIControlSet uIControlSet = this.CreateControlSet(); Dictionary <int, InputBehaviorWindow.PropertyType> dictionary = new Dictionary <int, InputBehaviorWindow.PropertyType>(); string customEntry = ControlMapper.GetLanguage().GetCustomEntry(inputBehaviorSettings.labelLanguageKey); if (!string.IsNullOrEmpty(customEntry)) { uIControlSet.SetTitle(customEntry); } else { uIControlSet.SetTitle(inputBehavior.name); } if (inputBehaviorSettings.showJoystickAxisSensitivity) { UISliderControl uISliderControl = this.CreateSlider(uIControlSet, inputBehavior.id, null, ControlMapper.GetLanguage().GetCustomEntry(inputBehaviorSettings.joystickAxisSensitivityLabelLanguageKey), inputBehaviorSettings.joystickAxisSensitivityIcon, inputBehaviorSettings.joystickAxisSensitivityMin, inputBehaviorSettings.joystickAxisSensitivityMax, new Action <int, int, float>(this.JoystickAxisSensitivityValueChanged), new Action <int, int>(this.JoystickAxisSensitivityCanceled)); uISliderControl.slider.value = Mathf.Clamp(inputBehavior.joystickAxisSensitivity, inputBehaviorSettings.joystickAxisSensitivityMin, inputBehaviorSettings.joystickAxisSensitivityMax); dictionary.Add(uISliderControl.id, InputBehaviorWindow.PropertyType.JoystickAxisSensitivity); } if (inputBehaviorSettings.showMouseXYAxisSensitivity) { UISliderControl uISliderControl2 = this.CreateSlider(uIControlSet, inputBehavior.id, null, ControlMapper.GetLanguage().GetCustomEntry(inputBehaviorSettings.mouseXYAxisSensitivityLabelLanguageKey), inputBehaviorSettings.mouseXYAxisSensitivityIcon, inputBehaviorSettings.mouseXYAxisSensitivityMin, inputBehaviorSettings.mouseXYAxisSensitivityMax, new Action <int, int, float>(this.MouseXYAxisSensitivityValueChanged), new Action <int, int>(this.MouseXYAxisSensitivityCanceled)); uISliderControl2.slider.value = Mathf.Clamp(inputBehavior.mouseXYAxisSensitivity, inputBehaviorSettings.mouseXYAxisSensitivityMin, inputBehaviorSettings.mouseXYAxisSensitivityMax); dictionary.Add(uISliderControl2.id, InputBehaviorWindow.PropertyType.MouseXYAxisSensitivity); } this.inputBehaviorInfo.Add(new InputBehaviorWindow.InputBehaviorInfo(inputBehavior, uIControlSet, dictionary)); } } } base.defaultUIElement = this.doneButton.gameObject; }
public void SetData(int playerId, Rewired.UI.ControlMapper.ControlMapper.InputBehaviorSettings[] data) { if (!this.initialized) { return; } this.playerId = playerId; for (int index = 0; index < data.Length; ++index) { Rewired.UI.ControlMapper.ControlMapper.InputBehaviorSettings behaviorSettings = data[index]; if (behaviorSettings != null && behaviorSettings.isValid) { InputBehavior inputBehavior = this.GetInputBehavior(behaviorSettings.inputBehaviorId); if (inputBehavior != null) { UIControlSet controlSet = this.CreateControlSet(); Dictionary <int, InputBehaviorWindow.PropertyType> idToProperty = new Dictionary <int, InputBehaviorWindow.PropertyType>(); string customEntry = Rewired.UI.ControlMapper.ControlMapper.GetLanguage().GetCustomEntry(behaviorSettings.labelLanguageKey); if (!string.IsNullOrEmpty(customEntry)) { controlSet.SetTitle(customEntry); } else { controlSet.SetTitle(inputBehavior.get_name()); } if (behaviorSettings.showJoystickAxisSensitivity) { UISliderControl slider = this.CreateSlider(controlSet, inputBehavior.get_id(), (string)null, Rewired.UI.ControlMapper.ControlMapper.GetLanguage().GetCustomEntry(behaviorSettings.joystickAxisSensitivityLabelLanguageKey), behaviorSettings.joystickAxisSensitivityIcon, behaviorSettings.joystickAxisSensitivityMin, behaviorSettings.joystickAxisSensitivityMax, new Action <int, int, float>(this.JoystickAxisSensitivityValueChanged), new Action <int, int>(this.JoystickAxisSensitivityCanceled)); slider.slider.set_value(Mathf.Clamp(inputBehavior.get_joystickAxisSensitivity(), behaviorSettings.joystickAxisSensitivityMin, behaviorSettings.joystickAxisSensitivityMax)); idToProperty.Add(slider.id, InputBehaviorWindow.PropertyType.JoystickAxisSensitivity); } if (behaviorSettings.showMouseXYAxisSensitivity) { UISliderControl slider = this.CreateSlider(controlSet, inputBehavior.get_id(), (string)null, Rewired.UI.ControlMapper.ControlMapper.GetLanguage().GetCustomEntry(behaviorSettings.mouseXYAxisSensitivityLabelLanguageKey), behaviorSettings.mouseXYAxisSensitivityIcon, behaviorSettings.mouseXYAxisSensitivityMin, behaviorSettings.mouseXYAxisSensitivityMax, new Action <int, int, float>(this.MouseXYAxisSensitivityValueChanged), new Action <int, int>(this.MouseXYAxisSensitivityCanceled)); slider.slider.set_value(Mathf.Clamp(inputBehavior.get_mouseXYAxisSensitivity(), behaviorSettings.mouseXYAxisSensitivityMin, behaviorSettings.mouseXYAxisSensitivityMax)); idToProperty.Add(slider.id, InputBehaviorWindow.PropertyType.MouseXYAxisSensitivity); } this.inputBehaviorInfo.Add(new InputBehaviorWindow.InputBehaviorInfo(inputBehavior, controlSet, idToProperty)); } } } this.defaultUIElement = ((Component)this.doneButton).get_gameObject(); }
public void SetData(int playerId, ControlMapper.InputBehaviorSettings[] data) { if (!initialized) { return; } this.playerId = playerId; // Create control sets for (int i = 0; i < data.Length; i++) { var item = data[i]; if (item == null || !item.isValid) { continue; } InputBehavior inputBehavior = GetInputBehavior(item.inputBehaviorId); if (inputBehavior == null) { continue; } UIControlSet set = CreateControlSet(); Dictionary <int, PropertyType> idToProperty = new Dictionary <int, PropertyType>();; // Set the title string customTitle = ControlMapper.GetLanguage().GetCustomEntry(item.labelLanguageKey); if (!string.IsNullOrEmpty(customTitle)) { set.SetTitle(customTitle); } else { set.SetTitle(inputBehavior.name); } // Create sliders if (item.showJoystickAxisSensitivity) { UISliderControl slider = CreateSlider( set, inputBehavior.id, null, ControlMapper.GetLanguage().GetCustomEntry(item.joystickAxisSensitivityLabelLanguageKey), item.joystickAxisSensitivityIcon, item.joystickAxisSensitivityMin, item.joystickAxisSensitivityMax, JoystickAxisSensitivityValueChanged, JoystickAxisSensitivityCanceled ); // Set initial value slider.slider.value = Mathf.Clamp(inputBehavior.joystickAxisSensitivity, item.joystickAxisSensitivityMin, item.joystickAxisSensitivityMax); // Store property type idToProperty.Add(slider.id, PropertyType.JoystickAxisSensitivity); } if (item.showMouseXYAxisSensitivity) { UISliderControl slider = CreateSlider( set, inputBehavior.id, null, ControlMapper.GetLanguage().GetCustomEntry(item.mouseXYAxisSensitivityLabelLanguageKey), item.mouseXYAxisSensitivityIcon, item.mouseXYAxisSensitivityMin, item.mouseXYAxisSensitivityMax, MouseXYAxisSensitivityValueChanged, MouseXYAxisSensitivityCanceled ); // Set initial value slider.slider.value = Mathf.Clamp(inputBehavior.mouseXYAxisSensitivity, item.mouseXYAxisSensitivityMin, item.mouseXYAxisSensitivityMax); // Store property type idToProperty.Add(slider.id, PropertyType.MouseXYAxisSensitivity); } // mouseOtherAxisSensitivity not implemented // Add to the list inputBehaviorInfo.Add(new InputBehaviorInfo(inputBehavior, set, idToProperty)); } // Set default UI element defaultUIElement = doneButton.gameObject; }