From 3f0d06b8b63b4de0fef05d0ee5120375d644414d Mon Sep 17 00:00:00 2001 From: unitydavidlo Date: Fri, 4 Dec 2026 11:34:49 +0000 Subject: [PATCH] FIX: [Port] Fixed CS0246 'InputSystemState' compile error in release Player builds with UNITY_INCLUDE_TESTS The 1.20.2 port of the trunk fix (ISX-2788) only brought over the InputSystem.remoteConnection change. The test framework assembly still needs InputSystemState, InputManager.SaveState and InputRemoting.SaveState, which were guarded by DEBUG and so missing in non-development Player builds that include test assemblies. Guard them with UNITY_EDITOR || UNITY_INCLUDE_TESTS as trunk does, and do the same for the DEVELOPMENT_BUILD guards in InputTestFixture. Co-Authored-By: Claude Opus 5.5 --- Packages/com.unity.inputsystem/CHANGELOG.md | 3 +++ .../InputSystem/Runtime/Devices/Remote/InputRemoting.cs | 4 ++-- .../com.unity.inputsystem/InputSystem/Runtime/InputManager.cs | 4 ++-- .../InputSystem/Runtime/InputSystemState.cs | 4 ++-- .../Tests/TestFixture/InputTestFixture.cs | 4 ++-- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Packages/com.unity.inputsystem/CHANGELOG.md b/Packages/com.unity.inputsystem/CHANGELOG.md index e79e09fc49..fb8c721748 100644 --- a/Packages/com.unity.inputsystem/CHANGELOG.md +++ b/Packages/com.unity.inputsystem/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] - yyyy-mm-dd +### Fixed + +- Fixed compilation error CS0246 (`The type or namespace name 'InputSystemState' could not be found`) in non-development Player builds that include test assemblies with the `UNITY_INCLUDE_TESTS` scripting define symbol set. The 1.20.2 fix for the related CS0117 `remoteConnection` error didn't cover the test framework assembly. ## [1.20.2] - 2026-12-03 diff --git a/Packages/com.unity.inputsystem/InputSystem/Runtime/Devices/Remote/InputRemoting.cs b/Packages/com.unity.inputsystem/InputSystem/Runtime/Devices/Remote/InputRemoting.cs index 30e2b8bcb0..c3a0604814 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Runtime/Devices/Remote/InputRemoting.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Runtime/Devices/Remote/InputRemoting.cs @@ -757,7 +757,7 @@ private static TData DeserializeData(byte[] data) return JsonUtility.FromJson(json); } -#if DEBUG +#if UNITY_EDITOR || UNITY_INCLUDE_TESTS // State we want to take across domain reloads. We can only take some of the // state across. Subscriptions will be lost and have to be manually restored. [Serializable] @@ -786,6 +786,6 @@ internal void RestoreState(SerializedState state, InputManager manager) m_Senders = state.senders; } -#endif +#endif // UNITY_EDITOR || UNITY_INCLUDE_TESTS } } diff --git a/Packages/com.unity.inputsystem/InputSystem/Runtime/InputManager.cs b/Packages/com.unity.inputsystem/InputSystem/Runtime/InputManager.cs index 6a0377c497..168c26413f 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Runtime/InputManager.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Runtime/InputManager.cs @@ -4522,7 +4522,7 @@ private bool FlipBuffersForDeviceIfNecessary(InputDevice device, InputUpdateType // Stuff everything that we want to survive a domain reload into // a m_SerializedState. - #if DEBUG + #if UNITY_EDITOR || UNITY_INCLUDE_TESTS [Serializable] internal struct DeviceState { @@ -4836,6 +4836,6 @@ private bool RestoreDeviceFromSavedState(ref DeviceState deviceState, InternedSt return true; } -#endif // DEBUG +#endif // UNITY_EDITOR || UNITY_INCLUDE_TESTS } } diff --git a/Packages/com.unity.inputsystem/InputSystem/Runtime/InputSystemState.cs b/Packages/com.unity.inputsystem/InputSystem/Runtime/InputSystemState.cs index 3ee3448b1b..8f9b6f2b9b 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Runtime/InputSystemState.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Runtime/InputSystemState.cs @@ -5,7 +5,7 @@ namespace UnityEngine.InputSystem { -#if DEBUG +#if UNITY_EDITOR || UNITY_INCLUDE_TESTS /// /// Snapshot of the state used by the input system. /// @@ -29,5 +29,5 @@ internal struct InputSystemState [NonSerialized] public ISavedState touchState; [NonSerialized] public ISavedState inputUserState; } -#endif +#endif // UNITY_EDITOR || UNITY_INCLUDE_TESTS } diff --git a/Packages/com.unity.inputsystem/Tests/TestFixture/InputTestFixture.cs b/Packages/com.unity.inputsystem/Tests/TestFixture/InputTestFixture.cs index cdb0a7ed17..4676bffe31 100644 --- a/Packages/com.unity.inputsystem/Tests/TestFixture/InputTestFixture.cs +++ b/Packages/com.unity.inputsystem/Tests/TestFixture/InputTestFixture.cs @@ -109,7 +109,7 @@ public virtual void Setup() runtime = new InputTestRuntime(); // Push current input system state on stack. -#if DEVELOPMENT_BUILD || UNITY_EDITOR +#if UNITY_EDITOR || UNITY_INCLUDE_TESTS m_StateManager.SaveAndReset(false, runtime); #endif // Override the editor messing with logic like canRunInBackground and focus and @@ -192,7 +192,7 @@ public virtual void TearDown() try { -#if DEVELOPMENT_BUILD || UNITY_EDITOR +#if UNITY_EDITOR || UNITY_INCLUDE_TESTS m_StateManager.Restore(); #endif runtime.Dispose();