Skip to content

Gate the native engine on the host OS, not the active build target - #439

Open
MonoFinity wants to merge 1 commit into
Voltstro-Studios:masterfrom
MonoFinity:fix/host-os-engine-gate
Open

Gate the native engine on the host OS, not the active build target#439
MonoFinity wants to merge 1 commit into
Voltstro-Studios:masterfrom
MonoFinity:fix/host-os-engine-gate

Conversation

@MonoFinity

@MonoFinity MonoFinity commented Jul 27, 2026

Copy link
Copy Markdown

The problem

UWB picks its native engine off the Unity active build target, but the engine is a native child process of the running Unity process — so in the Editor, the platform that matters is the one the Editor itself is running on.

Because the selection is keyed on UNITY_STANDALONE_* alone, a Windows Editor whose active build target is WebGL, Android or a console compiles:

  • WebBrowserUtils.GetRunningPlatform() down to throw new PlatformNotSupportedException(), and
  • EngineProcess's constructor down to nothing, leaving processHandle null so every member forwarding to it throws a NullReferenceException.

The practical effect is that UWB cannot be used in the Editor at all by any project that is not currently targeting Standalone. There is no runtime override for it — it's a compile-time gate, so no Engine subclass hook or asmdef arrangement works around it. Switching the build target to Standalone just to preview a webview is disruptive on a large project (it forces an asset re-import and invalidates the platform's script defines).

The change

Widen each gate to UNITY_STANDALONE_X || UNITY_EDITOR_X in the six places that select or compile the per-platform process wrapper:

File Gate
Helper/WebBrowserUtils.cs GetRunningPlatform()
Core/Engines/EngineProcess.cs ctor processHandle selection
Core/Engines/EngineConfiguration.cs GetEngineExecutableName() — a Windows Editor must still look for the .exe
Core/Engines/Process/WindowProcess.cs file guard
Core/Engines/Process/LinuxProcess.cs file guard
Core/Engines/Process/MacOsProcess.cs file guard

Player builds are unaffected

This only widens what compiles inside the Editor. A Standalone player defines UNITY_STANDALONE_X but not UNITY_EDITOR_X; a WebGL/Android player defines neither. Both keep the existing behaviour byte-for-byte.

Notes

  • Verified against master (f49743d).
  • We've been running this patch in a vendored copy of 2.2.8 for production Editor work on Windows, hosting a CEF-rendered React UI in the Game View with the build target set to WebGL.
  • Sent as a separate PR from Bound the TCP client's connect timeout instead of int.MaxValue #440 — the two are independent and either can be taken without the other.

The engine is a native child process of the running Unity process, so in the
Editor the platform that matters is the one the Editor itself runs on. Keying
the platform selection off UNITY_STANDALONE_* alone means a Windows Editor
whose active build target is WebGL, Android or a console compiles
WebBrowserUtils.GetRunningPlatform() down to
`throw new PlatformNotSupportedException()`, and EngineProcess leaves
processHandle null so every member forwarding to it throws a
NullReferenceException. UWB is therefore unusable in the Editor for any
project not currently targeting Standalone.

Widen each gate to UNITY_STANDALONE_X || UNITY_EDITOR_X in the five places
that select or compile the per-platform process wrapper, plus
GetEngineExecutableName so a Windows Editor still looks for the .exe.

Player builds are unaffected: a Standalone player defines only
UNITY_STANDALONE_X and a WebGL/Android player defines neither, so both keep
the existing behaviour exactly. The change only widens what compiles inside
the Editor.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant