Skip to content

Commit 67de004

Browse files
committed
Add back missing comments and profile markers
1 parent b0443a2 commit 67de004

1 file changed

Lines changed: 28 additions & 2 deletions

File tree

Packages/com.unity.inputsystem/Editor/InputSystemEditorInitializer.cs

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using Unity.Profiling;
34
using UnityEditor;
45
using UnityEditor.Networking.PlayerConnection;
56
using UnityEditorInternal;
@@ -18,6 +19,8 @@ internal static class InputSystemEditorInitializer
1819
private static InputSystemStateManager s_StateManager;
1920
internal static InputSystemStateManager stateManager => s_StateManager;
2021

22+
static readonly ProfilerMarker k_InputInitializeInEditorMarker = new ProfilerMarker("InputSystem.InitializeInEditor");
23+
2124
static InputSystemEditorInitializer()
2225
{
2326
OnGlobalInitialize(calledFromCtor: true);
@@ -134,7 +137,7 @@ private static void OnUIInputModuleReset(UnityEngine.InputSystem.UI.InputSystemU
134137

135138
if (asset != null)
136139
{
137-
UnityEngine.InputSystem.UI.Editor.InputSystemUIInputModuleEditor.ReassignActions(module, asset);
140+
UI.Editor.InputSystemUIInputModuleEditor.ReassignActions(module, asset);
138141
}
139142
}
140143

@@ -169,6 +172,8 @@ private static void OnGlobalInitialize(bool calledFromCtor)
169172

170173
internal static void InitializeInEditor(bool calledFromCtor, IInputRuntime runtime = null)
171174
{
175+
k_InputInitializeInEditorMarker.Begin();
176+
172177
bool globalReset = calledFromCtor || !IsDomainReloadDisabledForPlayMode();
173178

174179
// We must initialize a new InputManager object first thing since other parts
@@ -178,8 +183,8 @@ internal static void InitializeInEditor(bool calledFromCtor, IInputRuntime runti
178183
if (InputSystem.s_Manager != null)
179184
InputSystem.s_Manager.Dispose();
180185

186+
// Settings object should get set by an actual InputSettings asset.
181187
InputSystem.s_Manager = InputManager.CreateAndInitialize(runtime ?? NativeInputRuntime.instance, null);
182-
183188
EditorApplication.playModeStateChanged += OnEditorPlayModeStateChanged;
184189
EditorApplication.projectChanged += OnEditorProjectChanged;
185190

@@ -199,19 +204,30 @@ internal static void InitializeInEditor(bool calledFromCtor, IInputRuntime runti
199204
{
200205
if (globalReset)
201206
{
207+
////FIXME: does not preserve action map state
208+
209+
// If we're coming back out of a domain reload. We're restoring part of the
210+
// InputManager state here but we're still waiting from layout registrations
211+
// that happen during domain initialization.
212+
202213
s_StateManager = existingStateManagers[0];
203214
InputSystem.s_Manager.RestoreStateWithoutDevices(s_StateManager.systemState.managerState);
204215
InputDebuggerWindow.ReviveAfterDomainReload();
205216

217+
// Restore remoting state.
206218
InputSystem.remoteConnection = s_StateManager.systemState.remoteConnection;
207219
InputSystem.SetUpRemoting();
208220
InputSystem.s_Remote.RestoreState(s_StateManager.systemState.remotingState, InputSystem.s_Manager);
209221

222+
// Get s_Manager to restore devices on first input update. By that time we
223+
// should have all (possibly updated) layout information in place.
210224
InputSystem.s_Manager.m_SavedDeviceStates = s_StateManager.systemState.managerState.devices;
211225
InputSystem.s_Manager.m_SavedAvailableDevices = s_StateManager.systemState.managerState.availableDevices;
212226

227+
// Restore editor settings.
213228
InputEditorUserSettings.s_Settings = s_StateManager.systemState.userSettings;
214229

230+
// Get rid of saved state.
215231
s_StateManager.systemState = new InputSystemState();
216232
}
217233
}
@@ -220,12 +236,14 @@ internal static void InitializeInEditor(bool calledFromCtor, IInputRuntime runti
220236
s_StateManager = ScriptableObject.CreateInstance<InputSystemStateManager>();
221237
s_StateManager.hideFlags = HideFlags.HideAndDontSave;
222238

239+
// See if we have a settings asset in our EditorBuildSettings.
223240
if (EditorBuildSettings.TryGetConfigObject(InputSettingsProvider.kEditorBuildSettingsConfigKey,
224241
out InputSettings settingsAsset))
225242
{
226243
InputSystem.s_Manager.settings = settingsAsset;
227244
}
228245

246+
// See if we have a saved actions object
229247
var savedActions = ProjectWideActionsBuildProvider.actionsToIncludeInPlayerBuild;
230248
if (savedActions != null)
231249
InputSystem.s_Manager.actions = savedActions;
@@ -239,13 +257,21 @@ internal static void InitializeInEditor(bool calledFromCtor, IInputRuntime runti
239257

240258
UnityRemoteSupport.Initialize();
241259

260+
// If native backends for new input system aren't enabled, ask user whether we should enable them
261+
// (requires restart). We only ask once per session and don't ask when running in batch mode.
262+
// The warning is delayed to delay call (called a short while after the Asset are loaded, on Inspector
263+
// update) to make sure it doesn't pop up while the editor is still loading or assets are not fully loaded -
264+
// this would cancel the import of large assets that are dependent on the InputSystem package and import
265+
// it as a dependency.
242266
EditorApplication.delayCall += ShowRestartWarning;
243267

244268
InputSystem.RunInitialUpdate();
245269

246270
InputSystem.EnableActions();
247271

248272
InitializeEditorHooks();
273+
274+
k_InputInitializeInEditorMarker.End();
249275
}
250276

251277
private static void InitializeEditorHooks()

0 commit comments

Comments
 (0)