Path must be located in Assets/ folder error whenever trying to create input actions.

Greetings,

I have a new Unity 2023.3.23f1 2D URP project. I have installed the Input System and rebuilt the backend.
After adding a PlayerInput component and clicking Create Actions, no matter what I name it or what folder I select (even accepting the default folder Unity wants to put it in) I get this error:

Path must be located in Assets/ folder (got: ‘F:/dev/Unity Projects/Tutorials/Joust/Assets/test.inputactions’)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

I have rebooted, restarted Unity and consistently get this error.

I have done this several times in other projects so I’m baffled.
9012832--1242565--upload_2023-5-14_9-9-3.png

9012832--1242568--upload_2023-5-14_9-9-15.png


Any ideas?

I had the same problem, and I solved it by moving my work environment from an external SSD to my C drive. I think it’s probably a read or write permissions issue.

I found a workaround.

My version is 2022.3.45f1

The problem was caused by using absolute path in the Input System.

Double-click the error to access the PlayerInputEditor.cs file.
Then replace line 245 to line 296 with the code below and it should work.

if (GUILayout.Button(m_CreateActionsText, EditorStyles.miniButton, GUILayout.MaxWidth(120)))
{
// Request save file location.
var defaultFileName = Application.productName;
var path = EditorUtility.SaveFilePanelInProject(
“Create Input Actions Asset”,
defaultFileName,
InputActionAsset.Extension,
“Create a new input actions asset”
);

if (!string.IsNullOrEmpty(path))
{
    // Load default actions and update all GUIDs.
    var defaultActionsText = File.ReadAllText(kDefaultInputActionsAssetPath);
    var newActions = InputActionAsset.FromJson(defaultActionsText);
    foreach (var map in newActions.actionMaps)
    {
        map.m_Id = Guid.NewGuid().ToString();
        foreach (var action in map.actions)
            action.m_Id = Guid.NewGuid().ToString();
    }
    newActions.name = Path.GetFileNameWithoutExtension(path);
    var newActionsText = newActions.ToJson();

    // Write it out and tell the asset DB to pick it up.
    File.WriteAllText(path, newActionsText);

    // Import the new asset
    AssetDatabase.ImportAsset(path, ImportAssetOptions.ForceSynchronousImport);

    // Load imported object.
    var importedObject = AssetDatabase.LoadAssetAtPath<InputActionAsset>(path);

    // Set it on the PlayerInput component.
    m_ActionsProperty.objectReferenceValue = importedObject;
    serializedObject.ApplyModifiedProperties();

    // Open the asset.
    AssetDatabase.OpenAsset(importedObject);
}

}