public InputBindingPropertiesView( SerializedProperty bindingProperty, Action <FourCC> onChange = null, InputControlPickerState controlPickerState = null, string expectedControlLayout = null, ReadOnlyArray <InputControlScheme> controlSchemes = new ReadOnlyArray <InputControlScheme>(), IEnumerable <string> controlPathsToMatch = null) : base(InputActionSerializationHelpers.IsCompositeBinding(bindingProperty) ? "Composite" : "Binding", bindingProperty, onChange, expectedControlLayout) { m_BindingProperty = bindingProperty; m_GroupsProperty = bindingProperty.FindPropertyRelative("m_Groups"); m_PathProperty = bindingProperty.FindPropertyRelative("m_Path"); m_BindingGroups = m_GroupsProperty.stringValue.Split(InputBinding.Separator).ToList(); m_ExpectedControlLayout = expectedControlLayout; m_ControlSchemes = controlSchemes; var flags = (InputBinding.Flags)bindingProperty.FindPropertyRelative("m_Flags").intValue; m_IsPartOfComposite = (flags & InputBinding.Flags.PartOfComposite) != 0; m_IsComposite = (flags & InputBinding.Flags.Composite) != 0; // Set up control picker for m_Path. Not needed if the binding is a composite. if (!m_IsComposite) { m_ControlPickerState = controlPickerState ?? new InputControlPickerState(); m_ControlPathEditor = new InputControlPathEditor(m_PathProperty, m_ControlPickerState, OnPathChanged); m_ControlPathEditor.SetExpectedControlLayout(m_ExpectedControlLayout); if (controlPathsToMatch != null) { m_ControlPathEditor.SetControlPathsToMatch(controlPathsToMatch); } } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { if (m_PickerState == null) { m_PickerState = new InputControlPickerState(); } if (m_Editor == null) { m_Editor = new InputControlPathEditor(property, m_PickerState, () => property.serializedObject.ApplyModifiedProperties()); m_Editor.SetExpectedControlLayoutFromAttribute(); } EditorGUI.BeginProperty(position, label, property); m_Editor.OnGUI(position); EditorGUI.EndProperty(); }