DRAFT: Split Runtime and Editor code into separate assemblies#2321
DRAFT: Split Runtime and Editor code into separate assemblies#2321jfreire-unity wants to merge 78 commits intodevelopfrom
Conversation
- Move InputSystem/* to Runtime/ (preserving history) - Move InputSystem/Editor to Editor/ (preserving history) - Add meta files for new folder structure - Follows Unity package layout conventions - All file history preserved via git mv
Also exposes the required internals between assemblies.
This is done to avoid calling into Edito specific code. Instead, it will be called if Editor code has registered a callback.
Due to refactoring, a lot of paths still contained the InputSystem folder path that no longer exists. We only have Editor and Runtime folders.
Packages/com.unity.inputsystem/Editor/Plugins/HID/HIDSupportEditorInitializer.cs
Outdated
Show resolved
Hide resolved
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨🤖 Helpful? Please react with 👍/👎 | Questions❓Please reach out in Slack #ask-u-pr |
Some files were moved to other folders, after merging conflicts arise but since they showed as removed changes didn't land on the moved files. This commit is fixing this
Instable test fix solution: EditorInputControlLayoutCache.Refresh() could return early without holding a cache reference, causing "Must hold an instance reference" asserts after InputSystem.SaveAndReset() in tests. Now, Refresh() ensures a cache ref is held even on the early-return path.
…ble(): ensure CustomDevice restored from saved state Fix domain reload in InputSystem tests: ensure CustomDevice restored from saved state - SimulateDomainReload() now calls SimulateDomainReloadRecoveryFromSerializedState() - Clears InputSystem.devices and restores saved device states from serialized InputSystemObject - Ensures Editor_DomainReload_CustomDevicesAreRestoredAsLayoutsBecomeAvailable test passes
…meAvailable(): ensure CustomDevice restored from saved state" This reverts commit 24a6469.
…_SYSTEM_ENABLE_UI Fix compilation errors in VirtualMouseInputEditor.cs with UNITY_INPUT_SYSTEM_ENABLE_UI so it only compiles when UI runtime types are present
Updated error paths in pvp-exemptions.json for Switch plugins.
…nent.VirtualMouseInput) and TouchSimulator.cs with code split in TouchSimulationEditor.cs
|
/crc |
There was a problem hiding this comment.
The review has identified several critical issues that could impact build compilation and test stability, specifically regarding the separation of Editor and Runtime code. Key findings include Editor-only types referenced in Runtime contexts without proper platform defines, uninitialized fields during Editor resets that may break tests, and a problematic assembly dependency in the test framework. Additionally, some code cleanup is needed for residual merge markers and Editor performance optimizations.
🤖 Helpful? 👍/👎
| using UnityEditor; | ||
| using EditorHelpers = UnityEngine.Rendering.VirtualTexturing.EditorHelpers; |
There was a problem hiding this comment.
These using statements are placed outside of the #if UNITY_EDITOR block in a runtime script. This will cause compilation errors (CS0246: The type or namespace name 'UnityEditor' could not be found) when making Player builds.
Since the references to EditorHelpers inside the file were commented out, you can safely remove these, or at least move them inside the #if UNITY_EDITOR block below.
🤖 Helpful? 👍/👎
| #if UNITY_EDITOR | ||
| //m_Actions = ProjectWideActionsBuildProvider.actionsToIncludeInPlayerBuild; | ||
| #else |
There was a problem hiding this comment.
In the Editor, m_Actions is left uninitialized here since the assignment was commented out. This breaks test setups where InputSystem.Reset() is called (which internally creates a new manager and calls InitializeData()), as the new manager will have its actions field set to null and never restored.
You should use the newly added s_GetProjectWideActions delegate here:
#if UNITY_EDITOR
if (s_GetProjectWideActions != null)
m_Actions = s_GetProjectWideActions();
#else🤖 Helpful? 👍/👎
| { | ||
| #if UNITY_EDITOR | ||
| s_RemoteConnection = RemoteInputPlayerConnection.instance; | ||
| s_RemoteConnection.Bind(EditorConnection.instance, false); | ||
| #else | ||
| #if !UNITY_EDITOR | ||
| s_RemoteConnection = ScriptableObject.CreateInstance<RemoteInputPlayerConnection>(); | ||
| s_RemoteConnection.Bind(PlayerConnection.instance, PlayerConnection.instance.isConnected); | ||
| #endif | ||
| } |
There was a problem hiding this comment.
If enableRemoting is true in InputSystem.Reset(enableRemoting: true) or TestHook_InitializeForPlayModeTests(enableRemoting: true), it will call SetUpRemotingInternal(). But in the Editor, s_RemoteConnection will remain null here and the remote connection will silently fail to subscribe.
This will break any tests that rely on input remoting being correctly configured. A callback delegate like s_OnSetupRemoting should be added and invoked here so that InputSystemEditorInitializer can correctly inject the EditorConnection binding during resets.
🤖 Helpful? 👍/👎
| "references": [ | ||
| "Unity.InputSystem", | ||
| "UnityEngine.TestRunner", | ||
| "UnityEditor.TestRunner" | ||
| "UnityEditor.TestRunner", | ||
| "Unity.InputSystem.Editor" |
There was a problem hiding this comment.
Adding a hard dependency on Unity.InputSystem.Editor (which is an Editor-only assembly with "includePlatforms": ["Editor"]) to Unity.InputSystem.TestFramework (which is included on all platforms via "includePlatforms": []) will cause player builds of tests (such as Playmode tests on devices) to fail to compile due to a missing assembly reference.
To fix this, you should remove the direct assembly reference and instead use reflection to access the Editor initialization methods in SimulateDomainReload, or move the Editor-only test hooks into a separate Editor-only test assembly.
🤖 Helpful? 👍/👎
| s_OnMarkAsDirty?.Invoke(this); | ||
| //======= | ||
| // DirtyAssetTracker.TrackDirtyInputActionAsset(this); | ||
| //>>>>>>> develop:Packages/com.unity.inputsystem/InputSystem/Actions/InputActionAsset.cs |
| // Update Editor state in runtime | ||
| UpdateEditorState(); | ||
| EditorApplication.update += UpdateEditorState; | ||
|
|
There was a problem hiding this comment.
Have you considered using event-based updates for state tracking instead of polling? Instead of checking EditorApplication.isPlaying and EditorApplication.isPaused every frame via EditorApplication.update, you could subscribe to EditorApplication.playModeStateChanged and EditorApplication.pauseStateChanged. This would reduce unnecessary overhead in the Editor's main loop.
🤖 Helpful? 👍/👎
…e-split-for-module # Conflicts: # Packages/com.unity.inputsystem/Editor/InputSystemObject.cs # Packages/com.unity.inputsystem/Editor/InputSystemObject.cs.meta # Packages/com.unity.inputsystem/InputSystem/InputSystemObject.cs.meta # Packages/com.unity.inputsystem/Runtime/Actions/DeferBindingResolutionContext.cs # Packages/com.unity.inputsystem/Runtime/Actions/DeferBindingResolutionContext.cs.meta # Packages/com.unity.inputsystem/Runtime/Actions/InputActionAsset.cs # Packages/com.unity.inputsystem/Runtime/InputManager.cs # Packages/com.unity.inputsystem/Runtime/InputSystem.cs # Packages/com.unity.inputsystem/Runtime/InputSystemStateManager.cs # Packages/com.unity.inputsystem/Runtime/InputSystemStateManager.cs.meta # Packages/com.unity.inputsystem/Runtime/InputSystemTestHooks.cs # Packages/com.unity.inputsystem/Runtime/InputSystemTestHooks.cs.meta # Packages/com.unity.inputsystem/Runtime/Utilities/DirtyAssetTracker.cs # Packages/com.unity.inputsystem/Runtime/Utilities/DirtyAssetTracker.cs.meta # Packages/com.unity.inputsystem/Tests/TestFixture/InputTestFixture.cs # Packages/com.unity.inputsystem/ValidationExceptions.json
219f3dd to
02fdac7
Compare
Description
Please fill this section with a description what the pull request is trying to address and what changes were made.
Testing status & QA
Please describe the testing already done by you and what testing you request/recommend QA to execute. If you used or created any testing project please link them here too for QA.
Overall Product Risks
Please rate the potential complexity and halo effect from low to high for the reviewers. Note down potential risks to specific Editor branches if any.
Comments to reviewers
Please describe any additional information such as what to focus on, or historical info for the reviewers.
Checklist
Before review:
Changed,Fixed,Addedsections.Area_CanDoX,Area_CanDoX_EvenIfYIsTheCase,Area_WhenIDoX_AndYHappens_ThisIsTheResult.During merge:
NEW: ___.FIX: ___.DOCS: ___.CHANGE: ___.RELEASE: 1.1.0-preview.3.