diff --git a/src/Packages/UnityWebBrowser/Runtime/Core/Engines/EngineConfiguration.cs b/src/Packages/UnityWebBrowser/Runtime/Core/Engines/EngineConfiguration.cs index fc207b0c..8cb35308 100644 --- a/src/Packages/UnityWebBrowser/Runtime/Core/Engines/EngineConfiguration.cs +++ b/src/Packages/UnityWebBrowser/Runtime/Core/Engines/EngineConfiguration.cs @@ -29,7 +29,8 @@ public class EngineConfiguration : Engine public override string GetEngineExecutableName() { -#if UNITY_STANDALONE_WIN + //Host-OS gate: a Windows Editor must still look for the .exe whatever the build target. +#if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN return engineAppName + ".exe"; #else return engineAppName; diff --git a/src/Packages/UnityWebBrowser/Runtime/Core/Engines/EngineProcess.cs b/src/Packages/UnityWebBrowser/Runtime/Core/Engines/EngineProcess.cs index e2f0cbe6..07c6774c 100644 --- a/src/Packages/UnityWebBrowser/Runtime/Core/Engines/EngineProcess.cs +++ b/src/Packages/UnityWebBrowser/Runtime/Core/Engines/EngineProcess.cs @@ -29,11 +29,14 @@ internal sealed class EngineProcess : IDisposable /// public EngineProcess(Engine engine, IWebBrowserLogger logger) { -#if UNITY_STANDALONE_WIN + //Host-OS gate, matching WebBrowserUtils.GetRunningPlatform(). Without the editor + //defines processHandle stayed null in an Editor targeting a non-Standalone platform + //and every member that forwards to it threw a NullReferenceException. +#if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN processHandle = new WindowProcess(); -#elif UNITY_STANDALONE_LINUX +#elif UNITY_STANDALONE_LINUX || UNITY_EDITOR_LINUX processHandle = new LinuxProcess(logger); -#elif UNITY_STANDALONE_OSX +#elif UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX processHandle = new MacOsProcess(); #endif diff --git a/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process/LinuxProcess.cs b/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process/LinuxProcess.cs index 702de1f4..4bf43086 100644 --- a/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process/LinuxProcess.cs +++ b/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process/LinuxProcess.cs @@ -3,7 +3,8 @@ // // This project is under the MIT license. See the LICENSE.md file for more details. -#if UNITY_STANDALONE_LINUX +//Host-OS gate (parity with WindowProcess). +#if UNITY_STANDALONE_LINUX || UNITY_EDITOR_LINUX using System; using System.Collections.Generic; diff --git a/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process/MacOsProcess.cs b/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process/MacOsProcess.cs index 18e1297d..8c6acd54 100644 --- a/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process/MacOsProcess.cs +++ b/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process/MacOsProcess.cs @@ -6,7 +6,8 @@ using System.Diagnostics; using VoltstroStudios.UnityWebBrowser.Helper; -#if UNITY_STANDALONE_OSX +//Host-OS gate (parity with WindowProcess). +#if UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX namespace VoltstroStudios.UnityWebBrowser.Core.Engines.Process { diff --git a/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process/WindowProcess.cs b/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process/WindowProcess.cs index 71128203..fb81c335 100644 --- a/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process/WindowProcess.cs +++ b/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process/WindowProcess.cs @@ -3,7 +3,9 @@ // // This project is under the MIT license. See the LICENSE.md file for more details. -#if UNITY_STANDALONE_WIN +//Host-OS gate: this process wrapper has to compile for a Windows Editor whatever the +//active build target is, because the engine is a child process of the Editor itself. +#if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN using System; using System.ComponentModel; diff --git a/src/Packages/UnityWebBrowser/Runtime/Helper/WebBrowserUtils.cs b/src/Packages/UnityWebBrowser/Runtime/Helper/WebBrowserUtils.cs index 3f8d088a..aabdc1b6 100644 --- a/src/Packages/UnityWebBrowser/Runtime/Helper/WebBrowserUtils.cs +++ b/src/Packages/UnityWebBrowser/Runtime/Helper/WebBrowserUtils.cs @@ -140,11 +140,17 @@ public static bool GetScreenPointToLocalPositionDeltaOnImage(Graphic graphic, Ve /// public static Platform GetRunningPlatform() { -#if UNITY_STANDALONE_WIN + //Gated on the HOST OS, not the active build target. 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 - a Windows Editor targeting WebGL/Android/console + //still has to launch the Windows engine. Keying this off UNITY_STANDALONE_* alone made + //this throw in any Editor whose build target was not Standalone, which stopped UWB + //being usable in the Editor for those projects at all. +#if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN return Platform.Windows64; -#elif UNITY_STANDALONE_LINUX +#elif UNITY_STANDALONE_LINUX || UNITY_EDITOR_LINUX return Platform.Linux64; -#elif UNITY_STANDALONE_OSX +#elif UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX return System.Runtime.InteropServices.RuntimeInformation.ProcessArchitecture == System.Runtime.InteropServices.Architecture.Arm64 ? Platform.MacOSArm64 : Platform.MacOS; #else throw new PlatformNotSupportedException();