Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment on lines +32 to +33

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as comment on EngineProcess.

return engineAppName + ".exe";
#else
return engineAppName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@ internal sealed class EngineProcess : IDisposable
/// <param name="logger"></param>
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
Comment on lines +35 to +39

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A more better way would be to check the editor platform first, then check the target platform only if the build is not an editor. That way if someone is using Linux editor with the target set to Windows, it will start the Linux process in editor.

#if UNITY_EDITOR_WIN || (!UNITY_EDITOR && UNITY_STANDALONE_WIN)
            processHandle = new WindowProcess();
#elif UNITY_EDITOR_LINUX || (!UNITY_EDITOR && UNITY_STANDALONE_LINUX)
            processHandle = new LinuxProcess(logger);
#elif UNITY_EDITOR_OSX || (!UNITY_EDITOR && UNITY_STANDALONE_OSX)
            processHandle = new MacOsProcess();
#endif

processHandle = new MacOsProcess();
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 9 additions & 3 deletions src/Packages/UnityWebBrowser/Runtime/Helper/WebBrowserUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,17 @@ public static bool GetScreenPointToLocalPositionDeltaOnImage(Graphic graphic, Ve
/// <returns></returns>
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
Comment on lines +149 to +153

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as comment on EngineProcess.

return System.Runtime.InteropServices.RuntimeInformation.ProcessArchitecture == System.Runtime.InteropServices.Architecture.Arm64 ? Platform.MacOSArm64 : Platform.MacOS;
#else
throw new PlatformNotSupportedException();
Expand Down