// Context menu handler for "Delete Set".
        private void OnDeleteActionSet(object actionSetItemObject)
        {
            var actionSetItem = (ActionSetItem)actionSetItemObject;

            InputActionSerializationHelpers.DeleteActionSet(actionSetItem.property.serializedObject, actionSetItem.actionSetIndex);
            m_ApplyAction();
            Reload();
        }
Beispiel #2
0
        protected void AddActionSet()
        {
            InputActionSerializationHelpers.AddActionSet(serializedObject);
            ++m_ActionSetCount;

            Apply();

            if (m_ActionTreeView == null)
            {
                InitializeActionTreeView();
            }
            else
            {
                m_ActionTreeView.Reload();
            }
        }
        private void Initialize(SerializedProperty actionProperty, SerializedProperty actionSetProperty, bool displayHeader)
        {
            if (!displayHeader)
            {
                headerHeight = 2;
            }

            drawElementCallback =
                (rect, index, isActive, isFocused) =>
            {
                var binding = serializedProperty != null
                        ? serializedProperty.GetArrayElementAtIndex(index)
                        : (SerializedProperty)list[index];

                EditorGUI.PropertyField(rect, binding);
            };

            drawHeaderCallback =
                (rect) =>
            {
                if (displayHeader)
                {
                    EditorGUI.LabelField(rect, "Bindings");
                }
            };

            drawNoneElementCallback =
                (rect) =>
            {
                EditorGUI.LabelField(rect, s_NoBindingsText, EditorStyles.centeredGreyMiniLabel);
            };

            onAddCallback =
                (list) => InputActionSerializationHelpers.AppendBinding(actionProperty, actionSetProperty);

            onRemoveCallback =
                (list) => InputActionSerializationHelpers.RemoveBinding(actionProperty, list.index, actionSetProperty);
        }
        protected override void DoubleClickedItem(int id)
        {
            var item = FindItem(id, rootItem);

            if (item == null)
            {
                return;
            }

            var addNewAction = item as AddNewActionItem;

            if (addNewAction != null)
            {
                ////FIXME: for some reason, the item initially appears *before* other actions in the list and then later moves
                var actionSetItem = (ActionSetItem)addNewAction.parent;
                InputActionSerializationHelpers.AddAction(actionSetItem.property);
                m_ApplyAction();
                ////TODO: initiate rename right away
                Reload();
                return;
            }

            BeginRename(item);
        }