Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Packages/com.unity.inputsystem/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ however, it has to be formatted properly to pass verification tests.

## [Unreleased] - yyyy-mm-dd

### Fixed
- Fixed an issue where removing a newly created action in the Asset Editor would cause an exception. [UUM-95693](https://issuetracker.unity3d.com/product/unity/issues/guid/UUM-95693)

## [1.13.0] - 2025-02-05

### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ public static Command DeleteAction(int actionMapIndex, string actionName)
return (in InputActionsEditorState state) =>
{
var actionMap = Selectors.GetActionMapAtIndex(state, actionMapIndex)?.wrappedProperty;
var action = Selectors.GetActionInMap(state, actionMapIndex, actionName).wrappedProperty;
var action = Selectors.GetActionInMap(state, actionMapIndex, actionName)?.wrappedProperty;
var actionIndex = action.GetIndexOfArrayElement();
var actionID = InputActionSerializationHelpers.GetId(action);
var isCut = state.IsActionCut(actionMapIndex, actionIndex);
Expand Down Expand Up @@ -638,10 +638,17 @@ public static Command ChangeActionName(int actionMapIndex, string oldName, strin
return (in InputActionsEditorState state) =>
{
var actionMap = Selectors.GetActionMapAtIndex(state, actionMapIndex)?.wrappedProperty;
var action = Selectors.GetActionInMap(state, actionMapIndex, oldName).wrappedProperty;
InputActionSerializationHelpers.RenameAction(action, actionMap, newName);
state.serializedObject.ApplyModifiedProperties();
state.m_Analytics?.RegisterActionEdit();
var action = Selectors.GetActionInMap(state, actionMapIndex, oldName)?.wrappedProperty;
// In an Asset Editor workflow, the serialized property might not exist in case a new action is created
// that is yet to be named, and it's deleted before it's named.
// This is a particular case when ActionTreeView::DeleteItem triggers
// Focus callback -> OnEditTextFinished -> ChangeActionName.
if (action != null)
{
InputActionSerializationHelpers.RenameAction(action, actionMap, newName);
state.serializedObject.ApplyModifiedProperties();
state.m_Analytics?.RegisterActionEdit();
}
return state;
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,17 @@ public static SerializedProperty GetActionForIndex(SerializedProperty actionMap,
return actionMap.FindPropertyRelative(nameof(InputActionMap.m_Actions)).GetArrayElementAtIndex(actionIndex);
}

public static SerializedInputAction GetActionInMap(InputActionsEditorState state, int mapIndex, string name)
public static SerializedInputAction? GetActionInMap(InputActionsEditorState state, int mapIndex, string name)
{
return new SerializedInputAction(state.serializedObject
SerializedProperty property = state.serializedObject
?.FindProperty(nameof(InputActionAsset.m_ActionMaps))?.GetArrayElementAtIndex(mapIndex)
?.FindPropertyRelative(nameof(InputActionMap.m_Actions))
?.FirstOrDefault(p => p.FindPropertyRelative(nameof(InputAction.m_Name)).stringValue == name));
?.FirstOrDefault(p => p.FindPropertyRelative(nameof(InputAction.m_Name)).stringValue == name);

// If the action is not found, return null.
if (property == null)
return null;
return new SerializedInputAction(property);
}

public static SerializedInputBinding GetCompositeOrBindingInMap(SerializedProperty actionMap, int bindingIndex)
Expand Down