diff --git a/.github/workflows/check-runtime-editor-refs.yml b/.github/workflows/check-runtime-editor-refs.yml
new file mode 100644
index 0000000000..f5a0877563
--- /dev/null
+++ b/.github/workflows/check-runtime-editor-refs.yml
@@ -0,0 +1,20 @@
+name: Check Editor references in Runtime code
+
+on:
+ pull_request:
+ types:
+ - opened
+ - synchronize
+ - reopened
+ branches: [ "develop" ]
+
+ workflow_dispatch:
+
+jobs:
+ check-runtime-editor-refs:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Check Runtime code has no Editor namespace references
+ run: bash check-runtime-editor-refs.sh
\ No newline at end of file
diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/InputSystemEditorInitializer.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/InputSystemEditorInitializer.cs
index 657fe0de63..cb444898b7 100644
--- a/Packages/com.unity.inputsystem/InputSystem/Editor/InputSystemEditorInitializer.cs
+++ b/Packages/com.unity.inputsystem/InputSystem/Editor/InputSystemEditorInitializer.cs
@@ -277,6 +277,8 @@ private static void RegisterAssetDatabaseHooks()
InputManager.s_GetProjectWideActions = () => ProjectWideActionsBuildProvider.actionsToIncludeInPlayerBuild;
InputActionReference.s_CheckImmutableReference = CheckImmutableInputActionReference;
+
+ InputSettings.s_GetIsInspectorIndented = () => EditorGUI.indentLevel > 0;
}
///
diff --git a/Packages/com.unity.inputsystem/InputSystem/Runtime/InputSettings.cs b/Packages/com.unity.inputsystem/InputSystem/Runtime/InputSettings.cs
index 1fa27fc29e..08d5fcd86e 100644
--- a/Packages/com.unity.inputsystem/InputSystem/Runtime/InputSettings.cs
+++ b/Packages/com.unity.inputsystem/InputSystem/Runtime/InputSettings.cs
@@ -988,7 +988,10 @@ public enum InputActionPropertyDrawerMode
/// * support inspector view which only work in IMGUI for now.
/// * prevent the UI to be rendered in IMGUI and UI Toolkit in the Input Actions Editor window.
///
- public bool useIMGUIEditorForAssets => UnityEditor.EditorGUI.indentLevel > 0 || IsFeatureEnabled(InputFeatureNames.kUseIMGUIEditorForAssets);
+ public bool useIMGUIEditorForAssets =>
+ (s_GetIsInspectorIndented?.Invoke() == true) || IsFeatureEnabled(InputFeatureNames.kUseIMGUIEditorForAssets);
+
+ internal static Func s_GetIsInspectorIndented;
#endif
private static bool CompareFloats(float a, float b)
diff --git a/check-runtime-editor-refs.sh b/check-runtime-editor-refs.sh
new file mode 100755
index 0000000000..6dd9030af5
--- /dev/null
+++ b/check-runtime-editor-refs.sh
@@ -0,0 +1,67 @@
+#!/bin/bash
+[ -n "$BASH_VERSION" ] || { echo "ERROR: This script requires bash. Run with: bash $0" >&2; exit 1; }
+set -euo pipefail
+
+RUNTIME_DIR="Packages/com.unity.inputsystem/InputSystem/Runtime"
+
+# POSIX ERE patterns for grep -E, compatible with macOS (BSD grep) and Ubuntu (GNU grep).
+# No \b word boundaries — not portable across both. False positive risk is negligible
+# since no real identifiers contain these namespace roots as substrings.
+# (\.[A-Za-z0-9_]+)* covers sub-namespaces (UnityEditor.UI, …Editor.Tools, …).
+# Add more lines as needed, e.g. 'UnityEditorInternal(\.[A-Za-z0-9_]+)*'
+FORBIDDEN_REGEX=(
+ 'UnityEditor(\.[A-Za-z0-9_]+)*'
+ 'UnityEngine\.InputSystem\.Editor(\.[A-Za-z0-9_]+)*'
+)
+
+RED=$'\033[0;31m'
+GREEN=$'\033[0;32m'
+NC=$'\033[0m'
+
+INCLUDE_COMMENTS=false
+for arg in "$@"; do
+ case "$arg" in
+ --include-comments) INCLUDE_COMMENTS=true ;;
+ --help)
+ cat <&2; exit 1; }
+
+COMBINED=$(IFS='|'; echo "${FORBIDDEN_REGEX[*]}")
+
+GREP_OUTPUT=$(grep -rnw --include='*.cs' --color=never -E "$COMBINED" "$RUNTIME_DIR" || true)
+
+if [ "$INCLUDE_COMMENTS" = false ]; then
+ VIOLATIONS=$(echo "$GREP_OUTPUT" | grep -Ev ':[0-9]+:[[:space:]]*//' || true)
+else
+ VIOLATIONS="$GREP_OUTPUT"
+fi
+
+if [ -z "$VIOLATIONS" ]; then
+ echo "${GREEN}PASS: No Editor namespace references found in Runtime code.${NC}"
+ exit 0
+fi
+
+VIOLATION_COUNT=$(echo "$VIOLATIONS" | wc -l | tr -d ' ')
+echo "${RED}FAIL: Found $VIOLATION_COUNT Editor namespace reference(s) in Runtime code:${NC}"
+echo ""
+echo "$VIOLATIONS"
+echo ""
+echo "${RED}Active patterns:${NC}"
+for re in "${FORBIDDEN_REGEX[@]}"; do
+ printf ' \033[0;31m%s\033[0m\n' "$re"
+done
+exit 1