-
Notifications
You must be signed in to change notification settings - Fork 320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CHANGE: ISX-1865 Switch from InputManager.asset to asset-based storage for Project-wide actions #1834
Conversation
If I follow these steps I see a problem:
Problem seems to be related to the InputSystem.asset assignment. The check to see if the asset is already assigned passes as the assigned value has a instanceId that matches. Note - restarting editor and the asset is found again when opening the project settings In step 5 deleting the asset from the database, the InputSystem.actions still has a reference to that removed file. if we selected 'none' or a different asset and then reselect the newly created asset then the UI updates. |
Also the UX is different to the flow for creating the input settings - these don't pop up a location dialog Input settings don't ask for location when button clicked - they only ask for location when using the version from the menu on the cog icon (which isn't present in the project wide input actions editor ATM) ^ I've addressed this by making the button write the asset to a fixed location. Adding a drop down like the IMGUI settings version is more work and not critical in first pass. |
Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/AssetContext.cs
Outdated
Show resolved
Hide resolved
Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/AssetContext.cs
Outdated
Show resolved
Hide resolved
Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Commands/Commands.cs
Outdated
Show resolved
Hide resolved
Was asked to take a look early, here's my initial notes:
|
Fixed up some styles for the header
This is now added |
Fixed name in the json data when a new input action asset is created from the template
This is now fixed |
I'm seeing some issues in 2022.3.12f1 when selecting an input action asset NullReferenceException: Object reference not set to an instance of an object Appears to be an import error My latest commit fixes this |
…putSystem.actions is null InputSystem.actions is null at the start when no project wide input actions is set
(Default project wide input actions could be added to the project, but a user won't necessarily have them so adding messages so the user would know what to do if they are missing)
I think you mean ProjectWideActionsSampleScene |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hard to grasp the full logic at once. Just leaving minor comments, I think this is worth testing wisely (also considering the changes in CopyPaste).
Packages/com.unity.inputsystem/InputSystem/Editor/ProjectWideActions/ProjectWideActionsAsset.cs
Show resolved
Hide resolved
Packages/com.unity.inputsystem/InputSystem/Editor/ProjectWideActions/ProjectWideActionsAsset.cs
Show resolved
Hide resolved
Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Commands/Commands.cs
Show resolved
Hide resolved
First pass read-through looks good (long though, there's a lot to look at!) Will try some more testing on Monday. |
Packages/com.unity.inputsystem/InputSystem/Editor/ProjectWideActions/ProjectWideActionsAsset.cs
Outdated
Show resolved
Hide resolved
...m.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/InputActionsEditorSettingsProvider.cs
Outdated
Show resolved
Hide resolved
@@ -116,7 +116,7 @@ private void Destroy(Object obj) | |||
#if UNITY_EDITOR | |||
Object.DestroyImmediate(obj); | |||
#else | |||
Object.Destroy(actions); | |||
Object.DestroyImmediate(actions); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to documentation of Object.DestroyImmediate and Object.Destroy that should not be done? https://docs.unity3d.com/ScriptReference/Object.DestroyImmediate.html
@@ -3680,9 +3680,6 @@ private static void InitializeInPlayer(IInputRuntime runtime = null, InputSettin | |||
if (settings == null) | |||
settings = Resources.FindObjectsOfTypeAll<InputSettings>().FirstOrDefault() ?? ScriptableObject.CreateInstance<InputSettings>(); | |||
|
|||
if (actions == null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing this would completely bypass player loading of preloaded asset? Cannot see how this change is valid and would like to revert it. This area anyway need to be addressed additionally since there are existing problems with this an InputForUI integration. There are also related problems to static object stack push/pop within InputSystem/InputManager.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good spot.
I've reveted this and fixed 2 of the tests instead, with the knowledge that this can pickup an Asset from the test itself.
I am concerned with this way of loading the InputActionAsset though. If there are multiple in the project then it seems this could load the wrong one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree that this is too brittle, seems to be the same case for InputSwttings from previously. Likely needs an internal property serialized that allows tagging it unless there is a better way or use a dedicated path. This needs a ticket and a test case.
@@ -3524,6 +3555,12 @@ internal static void InitializeInEditor(IInputRuntime runtime = null) | |||
} | |||
s_SystemObject.newInputBackendsCheckedAsEnabled = true; | |||
|
|||
#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS | |||
// Make sure project wide input actions are enabled | |||
if (actions != null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the second time actions are enabled in this code path since also done via Reset above. Needs to be checked which of these is correct since Reset is also invoked when static state stack is pushed/popped.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The one in Reset is not used in Editor during the initialisation flow as its too early and at that point the value is null. So this line is needed then.
@@ -80,6 +80,8 @@ public void Initialize() | |||
|
|||
m_Cfg = Configuration.GetDefaultConfiguration(); | |||
RegisterActions(m_Cfg); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
InputSystem.actions and InputSystem.onActionsChange are only available when UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS is defined, but there are no symbolic checks here. In addition this is compiled into its own assembly so cannot detect symbols from Input System defines in asmdef and this seems to only rely on UNITY version which makes this broken if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS is undefined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, but that issue is not introduced by this PR.
…logies/InputSystem into isx-1865-project-wide-asset
…logies/InputSystem into isx-1865-project-wide-asset
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving to land. This addresses a lot of the main issues of the InputManager.asset storage.
Any further improvements can land in follow up PR's
Description
This branch switches from using InputManager.asset for storing project-wide actions to instead store them in an appointed .inputactions asset.
Changes made
InputSystem.actions
. If the default target filename already exist the user is prompted to overwrite or cancel the operation.Resources
. This is similar to howInputSettings
are handled.InputManager.asset
into a project-wide Input Actions asset instead. This is currently guarded with a static variable to only happen once per domain reload (throttling).InputSystem.onActionsChanged
which allows monitoring any changes to the property.Minor/technical:
Modified CopyPasteHelpers, SerializationHelpers to allow using buffer modification for any string buffer to enable utilising this functionality when replacing action maps within an existing asset.
Open/known issues that might need fixing before merge:
CoreTests_ProjectWideActions#ProjectWideActions_ThrowsWhenAddingOrRemovingWhileEnabled
(added recently by @timkeo) since its unclear how it should be treated in this new concepts. Needs to be determined.Notes
Suggestion for QA:
For any issues found we need to decide on a case-by-case basis whether it should be handled as a separate issue (and get this merged) or whether its an issue that may risk this concept not holding up and then we should fix it on this branch before merge.
Checklist
Before review:
Changed
,Fixed
,Added
sections.([case %number%](https://issuetracker.unity3d.com/issues/...))
.Area_CanDoX
,Area_CanDoX_EvenIfYIsTheCase
,Area_WhenIDoX_AndYHappens_ThisIsTheResult
.During merge:
NEW: ___
.FIX: ___
.DOCS: ___
.CHANGE: ___
.RELEASE: 1.1.0-preview.3
.