Gate the native engine on the host OS, not the active build target - #439
Open
MonoFinity wants to merge 1 commit into
Open
Gate the native engine on the host OS, not the active build target#439MonoFinity wants to merge 1 commit into
MonoFinity wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 tothrow new PlatformNotSupportedException(), andEngineProcess's constructor down to nothing, leavingprocessHandlenull so every member forwarding to it throws aNullReferenceException.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
Enginesubclass 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_Xin the six places that select or compile the per-platform process wrapper:Helper/WebBrowserUtils.csGetRunningPlatform()Core/Engines/EngineProcess.csprocessHandleselectionCore/Engines/EngineConfiguration.csGetEngineExecutableName()— a Windows Editor must still look for the.exeCore/Engines/Process/WindowProcess.csCore/Engines/Process/LinuxProcess.csCore/Engines/Process/MacOsProcess.csPlayer builds are unaffected
This only widens what compiles inside the Editor. A Standalone player defines
UNITY_STANDALONE_Xbut notUNITY_EDITOR_X; a WebGL/Android player defines neither. Both keep the existing behaviour byte-for-byte.Notes
master(f49743d).