-
Notifications
You must be signed in to change notification settings - Fork 329
FIX: Delayed input backend prompt to make sure asset import is not interrupted (ISXB-608) #2107
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
Changes from all commits
9f42a2b
b97e334
4974238
cd764b9
2d3243d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3599,14 +3599,29 @@ internal static void InitializeInEditor(IInputRuntime runtime = null) | |
| } | ||
|
|
||
| Debug.Assert(settings != null); | ||
| #if UNITY_EDITOR | ||
| Debug.Assert(EditorUtility.InstanceIDToObject(settings.GetInstanceID()) != null, | ||
| "InputSettings has lost its native object"); | ||
| #endif | ||
|
|
||
| // If native backends for new input system aren't enabled, ask user whether we should | ||
| // enable them (requires restart). We only ask once per session and don't ask when | ||
| // running in batch mode. | ||
| // The warning is delayed to delay call (called a short while after the Asset are loaded, on Inspector update) to make sure it doesn't pop up while the editor is still loading or assets are not fully loaded - | ||
| // this would cancel the import of large assets that are dependent on the InputSystem package and import it as a dependency. | ||
| EditorApplication.delayCall += ShowRestartWarning; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this guarantee that it will execute after asset import? I would have expected this to be triggered by an AssetP since this one will simply but the callback on the editor event queue? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The AssetPostProcessor was an other option I considered, but it requires another class to inherit from AssetPostprocessor, so I decided for delayedCall instead. delayCall is called after domain reloads (which include importing of assets at the end) when the inspector windows refresh, which I think is suitable for a prompt. I don't see why it's not robust, in which way do you think it couldn't be? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, yeah we have some classes doing that as part of InputActionImporter. If delayCall runs after domain reloads it's good, but to me it wasn't clear it runs after asset import (which might not trigger a domain reload if no code changed?). At least it's not explicit from https://docs.unity3d.com/6000.0/Documentation/ScriptReference/EditorApplication-delayCall.html, so it seems to relate to inspectors but not necessarily asset imports? Maybe you know something I do not in this area, but to me it wasn't clear that e.g. delayCall could be executed between two imports. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since InitializeInEditor is called from the static constructor it's only executed when the editor launches or the package gets added into the project (afaik - correct me if I forgot a case), in both cases there is a domain reload happening. |
||
|
|
||
| #if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would also be great to understand why this was moved out of its previous place? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I put it into a private function of the same class to make it more readable, I think having big chunks of code in single functions do no good for the readability some times. (technically still in the same place though) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure I see the function you are referring to? What I meant was basically that previously EnableActions(), RunInitialUpdate(), was executed from within ShowRestartWarning() as part of the deferred ShowRestartWarning. Now it executes directly in InitializeInEditor (before) code in ShowRestartWarning(). Hence why I asked if it still provides the same behavior or what the reason was for relocating it / changing the execution order. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It all is still in the same order, it may look a bit confusing just looking at the diffs, but the only thing I changed is outsourcing the logic of the prompt to a new private function called ShowRestartWarning() |
||
| // Make sure project wide input actions are enabled. | ||
| // Note that this will always fail if entering play-mode within editor since not yet in play-mode. | ||
| EnableActions(); | ||
| #endif | ||
|
|
||
| RunInitialUpdate(); | ||
|
|
||
| k_InputInitializeInEditorMarker.End(); | ||
| } | ||
|
|
||
| private static void ShowRestartWarning() | ||
| { | ||
| if (!s_SystemObject.newInputBackendsCheckedAsEnabled && | ||
| !EditorPlayerSettingHelpers.newSystemBackendsEnabled && | ||
| !s_Manager.m_Runtime.isInBatchMode) | ||
|
|
@@ -3622,16 +3637,7 @@ 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. | ||
| // Note that this will always fail if entering play-mode within editor since not yet in play-mode. | ||
| EnableActions(); | ||
| #endif | ||
|
|
||
| RunInitialUpdate(); | ||
|
|
||
| k_InputInitializeInEditorMarker.End(); | ||
| EditorApplication.delayCall -= ShowRestartWarning; | ||
| } | ||
|
|
||
| internal static void OnPlayModeChange(PlayModeStateChange change) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.