Skip to content

[DX-2731] feat: ability to target android or ios and run sdk in windows unity editor #176

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 6, 2024
Merged
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
2 changes: 1 addition & 1 deletion sample/Assets/Scripts/UnauthenticatedScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ async void Start()
#endif

passport = await Passport.Init(
#if UNITY_STANDALONE_WIN
#if UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN)
clientId, environment, redirectUri, logoutRedirectUri, 10000
#else
clientId, environment, redirectUri, logoutRedirectUri
Expand Down
6 changes: 3 additions & 3 deletions src/Packages/Passport/Editor/PassportPostprocess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ internal class PassportPostprocess : IPostprocessBuildWithReport

public void OnPostprocessBuild(BuildReport report)
{
Debug.Log("Passport post-processing...");
Debug.Log($"Passport post-processing...");

if (report.summary.result is BuildResult.Failed || report.summary.result is BuildResult.Cancelled)
return;
Expand Down Expand Up @@ -184,6 +184,6 @@ private void CopyFilesTo(string destinationPath)
}
}
}
}

}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System;
using Cysharp.Threading.Tasks;
using System.Collections.Generic;
#if UNITY_STANDALONE_WIN
#if UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN)
using VoltstroStudios.UnityWebBrowser.Core;
#else
using Immutable.Browser.Gree;
Expand Down
16 changes: 8 additions & 8 deletions src/Packages/Passport/Runtime/Scripts/Public/Passport.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using System;
#if UNITY_STANDALONE_WIN
#if UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN)
using VoltstroStudios.UnityWebBrowser.Core;
#else
using Immutable.Browser.Gree;
Expand All @@ -21,7 +21,7 @@ public class Passport

public static Passport Instance { get; private set; }

#if UNITY_STANDALONE_WIN
#if UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN)
private readonly IWebBrowserClient webBrowserClient = new WebBrowserClient();
#else
private readonly IWebBrowserClient webBrowserClient = new GreeBrowserClient();
Expand All @@ -36,7 +36,7 @@ public class Passport

private Passport()
{
#if UNITY_STANDALONE_WIN
#if UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN)
Application.quitting += OnQuit;
#elif UNITY_IPHONE || UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX
Application.deepLinkActivated += OnDeepLinkActivated;
Expand All @@ -57,7 +57,7 @@ private Passport()
/// <param name="logoutRedirectUri">(Android, iOS and macOS only) The URL to which auth will redirect the browser after log out is complete</param>
/// <param name="engineStartupTimeoutMs">(Windows only) Timeout time for waiting for the engine to start (in milliseconds)</param>
public static UniTask<Passport> Init(
#if UNITY_STANDALONE_WIN
#if UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN)
string clientId, string environment, string redirectUri = null, string logoutRedirectUri = null, int engineStartupTimeoutMs = 4000
#else
string clientId, string environment, string redirectUri = null, string logoutRedirectUri = null
Expand All @@ -70,7 +70,7 @@ public static UniTask<Passport> Init(
Instance = new Passport();
// Wait until we get a ready signal
return Instance.Initialise(
#if UNITY_STANDALONE_WIN
#if UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN)
engineStartupTimeoutMs
#endif
)
Expand Down Expand Up @@ -101,7 +101,7 @@ public static UniTask<Passport> Init(
}

private async UniTask Initialise(
#if UNITY_STANDALONE_WIN
#if UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN)
int engineStartupTimeoutMs
#endif
)
Expand All @@ -110,7 +110,7 @@ int engineStartupTimeoutMs
{
BrowserCommunicationsManager communicationsManager = new BrowserCommunicationsManager(webBrowserClient);
communicationsManager.OnReady += () => readySignalReceived = true;
#if UNITY_STANDALONE_WIN
#if UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN)
await ((WebBrowserClient)webBrowserClient).Init(engineStartupTimeoutMs);
#endif
passportImpl = new PassportImpl(communicationsManager);
Expand All @@ -125,7 +125,7 @@ int engineStartupTimeoutMs
}
}

#if UNITY_STANDALONE_WIN
#if UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN)
private void OnQuit()
{
// Need to clean up UWB resources when quitting the game in the editor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ public void LaunchAuthURL(string url, string redirectUri)
if (webView == IntPtr.Zero)
return;
_CWebViewPlugin_LaunchAuthURL(webView, url, redirectUri != null ? redirectUri : "");
#elif UNITY_IPHONE
#elif UNITY_IPHONE && !UNITY_EDITOR_WIN
if (webView == IntPtr.Zero)
return;
_CWebViewPlugin_LaunchAuthURL(webView, url);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if UNITY_STANDALONE_WIN
#if UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN)

// UnityWebBrowser (UWB)
// Copyright (c) 2021-2022 Voltstro-Studios
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if UNITY_STANDALONE_WIN
#if UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN)

// UnityWebBrowser (UWB)
// Copyright (c) 2021-2022 Voltstro-Studios
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if UNITY_STANDALONE_WIN
#if UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN)

// UnityWebBrowser (UWB)
// Copyright (c) 2021-2022 Voltstro-Studios
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if UNITY_STANDALONE_WIN
#if UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN)

// UnityWebBrowser (UWB)
// Copyright (c) 2021-2022 Voltstro-Studios
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if UNITY_STANDALONE_WIN
#if UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN)

// UnityWebBrowser (UWB)
// Copyright (c) 2021-2022 Voltstro-Studios
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if UNITY_STANDALONE_WIN
#if UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN)

// UnityWebBrowser (UWB)
// Copyright (c) 2021-2022 Voltstro-Studios
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if UNITY_STANDALONE_WIN
#if UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN)

// UnityWebBrowser (UWB)
// Copyright (c) 2021-2022 Voltstro-Studios
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if UNITY_STANDALONE_WIN
#if UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN)

// UnityWebBrowser (UWB)
// Copyright (c) 2021-2022 Voltstro-Studios
Expand Down Expand Up @@ -248,6 +248,10 @@ public IWebBrowserLogger Logger

public WebBrowserClient()
{
#if (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN)
UnityEngine.Debug.LogWarning("Native Android and iOS WebViews cannot run in the Editor, so the Windows WebView is currently used to save your development time." +
" Testing your game on an actual device or emulator is recommended to ensure proper functionality.");
#endif
}

/// <summary>
Expand Down Expand Up @@ -312,7 +316,7 @@ public async UniTask Init(int engineStartupTimeout = 4000)
#if UNITY_EDITOR
filePath = Constants.SCHEME_FILE + Path.GetFullPath($"{PASSPORT_PACKAGE_RESOURCES_DIRECTORY}{Constants.PASSPORT_HTML_FILE_NAME}");
#else
#if UNITY_STANDALONE_WIN
#if UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN)
filePath = Constants.SCHEME_FILE + Path.GetFullPath(Application.dataPath) + Constants.PASSPORT_DATA_DIRECTORY_NAME + Constants.PASSPORT_HTML_FILE_NAME;
#endif
#endif
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if UNITY_STANDALONE_WIN
#if UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN)

// UnityWebBrowser (UWB)
// Copyright (c) 2021-2022 Voltstro-Studios
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//
// This project is under the MIT license. See the LICENSE.md file for more details.

#if UNITY_EDITOR && UNITY_STANDALONE_WIN
#if UNITY_EDITOR && (UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN))

using System.IO;
using System.Linq;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if UNITY_STANDALONE_WIN
#if UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN)

// UnityWebBrowser (UWB)
// Copyright (c) 2021-2022 Voltstro-Studios
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if UNITY_STANDALONE_WIN
#if UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN)

// UnityWebBrowser (UWB)
// Copyright (c) 2021-2022 Voltstro-Studios
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if UNITY_STANDALONE_WIN
#if UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN)

// UnityWebBrowser (UWB)
// Copyright (c) 2021-2022 Voltstro-Studios
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if UNITY_STANDALONE_WIN
#if UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN)

// UnityWebBrowser (UWB)
// Copyright (c) 2021-2022 Voltstro-Studios
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if UNITY_STANDALONE_WIN
#if UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN)

// UnityWebBrowser (UWB)
// Copyright (c) 2021-2022 Voltstro-Studios
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if UNITY_STANDALONE_WIN
#if UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN)

// UnityWebBrowser (UWB)
// Copyright (c) 2021-2022 Voltstro-Studios
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if UNITY_STANDALONE_WIN
#if UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN)

// UnityWebBrowser (UWB)
// Copyright (c) 2021-2022 Voltstro-Studios
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if UNITY_STANDALONE_WIN
#if UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN)

// UnityWebBrowser (UWB)
// Copyright (c) 2021-2022 Voltstro-Studios
Expand Down Expand Up @@ -83,7 +83,7 @@ public static string GetBrowserEngineProcessPath(Engine engine)
return EngineManager.GetEngineProcessFullPath(engine);
#else
string path = $"{GetBrowserEnginePath(null)}/{engine.GetEngineExecutableName()}";
#if UNITY_STANDALONE_WIN
#if UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN)
path += ".exe";
#endif
return Path.GetFullPath(path);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if UNITY_STANDALONE_WIN
#if UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN)

// UnityWebBrowser (UWB)
// Copyright (c) 2021-2022 Voltstro-Studios
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if UNITY_STANDALONE_WIN
#if UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN)

// UnityWebBrowser (UWB)
// Copyright (c) 2021-2022 Voltstro-Studios
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if UNITY_STANDALONE_WIN
#if UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN)

// UnityWebBrowser (UWB)
// Copyright (c) 2021-2022 Voltstro-Studios
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if UNITY_STANDALONE_WIN
#if UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN)

// UnityWebBrowser (UWB)
// Copyright (c) 2021-2022 Voltstro-Studios
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if UNITY_STANDALONE_WIN
#if UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN)

// UnityWebBrowser (UWB)
// Copyright (c) 2021-2022 Voltstro-Studios
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if UNITY_STANDALONE_WIN
#if UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN)

// UnityWebBrowser (UWB)
// Copyright (c) 2021-2022 Voltstro-Studios
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if UNITY_STANDALONE_WIN
#if UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN)

// UnityWebBrowser (UWB)
// Copyright (c) 2021-2022 Voltstro-Studios
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if UNITY_STANDALONE_WIN
#if UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN)

// UnityWebBrowser (UWB)
// Copyright (c) 2021-2022 Voltstro-Studios
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if UNITY_STANDALONE_WIN
#if UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN)

// UnityWebBrowser (UWB)
// Copyright (c) 2021-2022 Voltstro-Studios
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if UNITY_STANDALONE_WIN
#if UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN)

// UnityWebBrowser (UWB)
// Copyright (c) 2021-2022 Voltstro-Studios
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if UNITY_STANDALONE_WIN
#if UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN)

// UnityWebBrowser (UWB)
// Copyright (c) 2021-2022 Voltstro-Studios
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if UNITY_STANDALONE_WIN
#if UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN)

// UnityWebBrowser (UWB)
// Copyright (c) 2021-2022 Voltstro-Studios
Expand Down