Skip to content

Commit 9b6571e

Browse files
committed
chore: resolve conflicts
1 parent 01fdea8 commit 9b6571e

23 files changed

+362
-27
lines changed

src/Packages/Passport/Runtime/Scripts/Private/Core/BrowserCommunicationsManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace Immutable.Passport.Core
1515

1616
public interface IBrowserCommunicationsManager
1717
{
18-
#if (UNITY_ANDROID && !UNITY_EDITOR_WIN) || (UNITY_IPHONE && !UNITY_EDITOR_WIN) || UNITY_STANDALONE_OSX
18+
#if (UNITY_ANDROID && !UNITY_EDITOR_WIN) || (UNITY_IPHONE && !UNITY_EDITOR_WIN) || UNITY_STANDALONE_OSX || UNITY_WEBGL
1919
event OnUnityPostMessageDelegate OnAuthPostMessage;
2020
event OnUnityPostMessageErrorDelegate OnPostMessageError;
2121
#endif
@@ -58,7 +58,7 @@ public BrowserCommunicationsManager(IWebBrowserClient webBrowserClient)
5858
{
5959
this.webBrowserClient = webBrowserClient;
6060
this.webBrowserClient.OnUnityPostMessage += InvokeOnUnityPostMessage;
61-
#if (UNITY_ANDROID && !UNITY_EDITOR_WIN) || (UNITY_IPHONE && !UNITY_EDITOR_WIN) || UNITY_STANDALONE_OSX
61+
#if (UNITY_ANDROID && !UNITY_EDITOR_WIN) || (UNITY_IPHONE && !UNITY_EDITOR_WIN) || UNITY_STANDALONE_OSX || UNITY_WEBGL
6262
this.webBrowserClient.OnAuthPostMessage += InvokeOnAuthPostMessage;
6363
this.webBrowserClient.OnPostMessageError += InvokeOnPostMessageError;
6464
#endif

src/Packages/Passport/Runtime/Scripts/Private/Immutable.Passport.Runtime.Private.asmdef

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"Editor",
1414
"iOS",
1515
"macOSStandalone",
16-
"WindowsStandalone64"
16+
"WindowsStandalone64",
17+
"WebGL"
1718
],
1819
"excludePlatforms": [],
1920
"allowUnsafeCode": false,

src/Packages/Passport/Runtime/Scripts/Private/PassportImpl.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public async UniTask Init(string clientId, string environment, string redirectUr
5555
this.redirectUri = redirectUri;
5656
this.logoutRedirectUri = logoutRedirectUri;
5757

58-
#if (UNITY_ANDROID && !UNITY_EDITOR_WIN) || (UNITY_IPHONE && !UNITY_EDITOR_WIN) || UNITY_STANDALONE_OSX
58+
#if (UNITY_ANDROID && !UNITY_EDITOR_WIN) || (UNITY_IPHONE && !UNITY_EDITOR_WIN) || UNITY_STANDALONE_OSX || UNITY_WEBGL
5959
this.communicationsManager.OnAuthPostMessage += OnDeepLinkActivated;
6060
this.communicationsManager.OnPostMessageError += OnPostMessageError;
6161
#endif
@@ -94,7 +94,7 @@ public async UniTask Init(string clientId, string environment, string redirectUr
9494
};
9595
initRequest = JsonUtility.ToJson(request);
9696
}
97-
97+
9898
string response = await communicationsManager.Call(PassportFunction.INIT, initRequest);
9999
BrowserResponse initResponse = response.OptDeserializeObject<BrowserResponse>();
100100

@@ -317,12 +317,17 @@ public async void OnDeepLinkActivated(string url)
317317
PassportLogger.Info($"{TAG} Received deeplink URL: {url}");
318318

319319
Uri uri = new Uri(url);
320-
string domain = $"{uri.Scheme}://{uri.Host}{uri.AbsolutePath}";
320+
string hostWithPort = uri.IsDefaultPort ? uri.Host : $"{uri.Host}:{uri.Port}";
321+
322+
string domain = $"{uri.Scheme}://{hostWithPort}{uri.AbsolutePath}";
323+
PassportLogger.Info($"{TAG} domain: {domain}");
324+
PassportLogger.Info($"{TAG} redirectUri: {redirectUri}");
325+
321326
if (domain.EndsWith("/"))
322327
{
323328
domain = domain.Remove(domain.Length - 1);
324329
}
325-
330+
326331
if (domain.Equals(logoutRedirectUri))
327332
{
328333
HandleLogoutPKCESuccess();

src/Packages/Passport/Runtime/Scripts/Public/Immutable.Passport.Runtime.asmdef

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"Editor",
1515
"iOS",
1616
"macOSStandalone",
17-
"WindowsStandalone64"
17+
"WindowsStandalone64",
18+
"WebGL"
1819
],
1920
"excludePlatforms": [],
2021
"allowUnsafeCode": false,

src/Packages/Passport/Runtime/Scripts/Public/Passport.cs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using VoltstroStudios.UnityWebBrowser.Core;
66
using VoltstroStudios.UnityWebBrowser.Shared;
77
#endif
8-
#elif (UNITY_ANDROID && !UNITY_EDITOR_WIN) || (UNITY_IPHONE && !UNITY_EDITOR_WIN) || UNITY_STANDALONE_OSX
8+
#elif (UNITY_ANDROID && !UNITY_EDITOR_WIN) || (UNITY_IPHONE && !UNITY_EDITOR_WIN) || UNITY_STANDALONE_OSX || UNITY_WEBGL
99
using Immutable.Browser.Gree;
1010
#endif
1111
using Immutable.Passport.Event;
@@ -181,18 +181,22 @@ private async UniTask Initialise(
181181
await ((WebBrowserClient)this.webBrowserClient).Init(engineStartupTimeoutMs);
182182
#endif
183183
}
184-
#elif (UNITY_ANDROID && !UNITY_EDITOR_WIN) || (UNITY_IPHONE && !UNITY_EDITOR_WIN) || UNITY_STANDALONE_OSX
184+
#elif (UNITY_ANDROID && !UNITY_EDITOR_WIN) || (UNITY_IPHONE && !UNITY_EDITOR_WIN) || UNITY_STANDALONE_OSX || UNITY_WEBGL
185185
// Initialise default browser client for Android, iOS, and macOS
186186
webBrowserClient = new GreeBrowserClient();
187187
#else
188188
throw new PassportException("Platform not supported");
189189
#endif
190190

191191
// Set up browser communication
192-
BrowserCommunicationsManager communicationsManager = new BrowserCommunicationsManager(webBrowserClient);
193-
// Mark ready when browser is initialised and game bridge file is loaded
194-
communicationsManager.OnReady += () => readySignalReceived = true;
195-
192+
BrowserCommunicationsManager communicationsManager = new BrowserCommunicationsManager(webBrowserClient);
193+
194+
#if UNITY_WEBGL
195+
readySignalReceived = true;
196+
#else
197+
// Mark ready when browser is initialised and game bridge file is loaded
198+
communicationsManager.OnReady += () => readySignalReceived = true;
199+
#endif
196200
// Set up Passport implementation
197201
passportImpl = new PassportImpl(communicationsManager);
198202
// Subscribe to Passport authentication events
@@ -237,7 +241,7 @@ public async UniTask<bool> ConnectImx(bool useCachedSession = false, Nullable<lo
237241
return await GetPassportImpl().ConnectImx(useCachedSession, timeoutMs);
238242
}
239243

240-
#if (UNITY_ANDROID && !UNITY_EDITOR_WIN) || (UNITY_IPHONE && !UNITY_EDITOR_WIN) || UNITY_STANDALONE_OSX
244+
#if (UNITY_ANDROID && !UNITY_EDITOR_WIN) || (UNITY_IPHONE && !UNITY_EDITOR_WIN) || UNITY_STANDALONE_OSX || UNITY_WEBGL
241245
/// <summary>
242246
/// Connects the user into Passport via PKCE auth.
243247
/// </summary>

src/Packages/Passport/Runtime/ThirdParty/Gree/Assets/Plugins/GreeBrowserClient.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
#if (UNITY_ANDROID && !UNITY_EDITOR_WIN) || (UNITY_IPHONE && !UNITY_EDITOR_WIN) || UNITY_STANDALONE_OSX
1+
#if (UNITY_ANDROID && !UNITY_EDITOR_WIN) || (UNITY_IPHONE && !UNITY_EDITOR_WIN) || UNITY_STANDALONE_OSX || UNITY_WEBGL
22

33
using Immutable.Browser.Core;
44
using Immutable.Passport.Core.Logging;
5+
using UnityEngine;
56

67
namespace Immutable.Browser.Gree
78
{
@@ -20,7 +21,12 @@ public GreeBrowserClient()
2021
PassportLogger.Warn("Native Android and iOS WebViews cannot run in the Editor, so the macOS WebView is currently used to save your development time." +
2122
" Testing your game on an actual device or emulator is recommended to ensure proper functionality.");
2223
#endif
24+
#if UNITY_WEBGL && !UNITY_EDITOR
25+
GameObject webViewGameObject = new GameObject("WebViewObject");
26+
webViewObject = webViewGameObject.AddComponent<WebViewObject>();
27+
#else
2328
webViewObject = new WebViewObject();
29+
#endif
2430
webViewObject.Init(
2531
cb: InvokeOnUnityPostMessage,
2632
httpErr: InvokeOnPostMessageError,

src/Packages/Passport/Runtime/ThirdParty/Gree/Assets/Plugins/WebGLTemplates.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Packages/Passport/Runtime/ThirdParty/Gree/Assets/Plugins/WebGLTemplates/unity-webview.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<!DOCTYPE html>
2+
<html lang="en-us">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6+
<title>Unity WebGL Player | Immutable Runner</title>
7+
<link rel="shortcut icon" href="TemplateData/favicon.ico">
8+
<link rel="stylesheet" href="TemplateData/style.css">
9+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
10+
<script src="unity-webview.js"></script>
11+
</head>
12+
<body>
13+
<div id="unity-container" class="unity-desktop">
14+
<div id="unity-build-title">Logging in</div>
15+
</div>
16+
<script>
17+
window.opener.postMessage({
18+
type: 'callback',
19+
url: window.location.href,
20+
});
21+
window.close();
22+
</script>
23+
</body>
24+
</html>

src/Packages/Passport/Runtime/ThirdParty/Gree/Assets/Plugins/WebGLTemplates/unity-webview/callback.html.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
<!DOCTYPE html>
2+
<html lang="en-us">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6+
<title>Unity WebGL Player | Immutable Runner</title>
7+
<link rel="shortcut icon" href="TemplateData/favicon.ico">
8+
<link rel="stylesheet" href="TemplateData/style.css">
9+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
10+
<script src="unity-webview.js"></script>
11+
</head>
12+
<body>
13+
<div id="unity-container" class="unity-desktop">
14+
<canvas id="unity-canvas"></canvas>
15+
<div id="unity-loading-bar">
16+
<div id="unity-logo"></div>
17+
<div id="unity-progress-bar-empty">
18+
<div id="unity-progress-bar-full"></div>
19+
</div>
20+
</div>
21+
<div id="unity-footer">
22+
<div id="unity-webgl-logo"></div>
23+
<div id="unity-fullscreen-button"></div>
24+
<div id="unity-build-title">Immutable Runner</div>
25+
</div>
26+
</div>
27+
<script>
28+
var buildUrl = "Build";
29+
var loaderUrl = buildUrl + "/webgl.loader.js";
30+
var config = {
31+
dataUrl: buildUrl + "/webgl.data.br",
32+
frameworkUrl: buildUrl + "/webgl.framework.js.br",
33+
codeUrl: buildUrl + "/webgl.wasm.br",
34+
streamingAssetsUrl: "StreamingAssets",
35+
companyName: "Immutable",
36+
productName: "Immutable Runner",
37+
productVersion: "0.1.0",
38+
};
39+
40+
var container = document.querySelector("#unity-container");
41+
var canvas = document.querySelector("#unity-canvas");
42+
var loadingBar = document.querySelector("#unity-loading-bar");
43+
var progressBarFull = document.querySelector("#unity-progress-bar-full");
44+
var fullscreenButton = document.querySelector("#unity-fullscreen-button");
45+
var width0 = "960px";
46+
var height0 = "600px";
47+
48+
if (/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)) {
49+
container.className = "unity-mobile";
50+
config.devicePixelRatio = 1;
51+
} else {
52+
canvas.style.width = "960px";
53+
canvas.style.height = "600px";
54+
}
55+
loadingBar.style.display = "block";
56+
57+
document.addEventListener(
58+
'fullscreenchange',
59+
function() {
60+
var p = document.getElementById('unity-container');
61+
var c = document.getElementById('unity-canvas');
62+
if (document.fullscreenElement) {
63+
width0 = c.style.width;
64+
height0 = c.style.height;
65+
setTimeout(
66+
function() {
67+
c.style.width = getComputedStyle(p).width;
68+
c.style.height = getComputedStyle(p).height;
69+
},
70+
250);
71+
} else {
72+
c.style.width = width0;
73+
c.style.height = height0;
74+
}
75+
});
76+
var script = document.createElement("script");
77+
script.src = loaderUrl;
78+
script.onload = () => {
79+
createUnityInstance(canvas, config, (progress) => {
80+
progressBarFull.style.width = 100 * progress + "%";
81+
}).then((unityInstance) => {
82+
window.unityInstance = unityInstance;
83+
loadingBar.style.display = "none";
84+
fullscreenButton.onclick = () => {
85+
var p = document.getElementById('unity-container');
86+
var c = document.getElementById('unity-canvas');
87+
c.requestFullscreen = () => {
88+
p.requestFullscreen();
89+
};
90+
unityInstance.SetFullscreen(1);
91+
};
92+
}).catch((message) => {
93+
alert(message);
94+
});
95+
};
96+
document.body.appendChild(script);
97+
</script>
98+
</body>
99+
</html>

src/Packages/Passport/Runtime/ThirdParty/Gree/Assets/Plugins/WebGLTemplates/unity-webview/index.html.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<!DOCTYPE html>
2+
<html lang="en-us">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6+
<title>Unity WebGL Player | Immutable Runner</title>
7+
<link rel="shortcut icon" href="TemplateData/favicon.ico">
8+
<link rel="stylesheet" href="TemplateData/style.css">
9+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
10+
<script src="unity-webview.js"></script>
11+
</head>
12+
<body>
13+
<div id="unity-container" class="unity-desktop">
14+
<div id="unity-build-title">Logging out</div>
15+
</div>
16+
<script>
17+
window.opener.postMessage({
18+
type: 'logout',
19+
url: window.location.href,
20+
});
21+
window.close();
22+
</script>
23+
</body>
24+
</html>

src/Packages/Passport/Runtime/ThirdParty/Gree/Assets/Plugins/WebGLTemplates/unity-webview/logout.html.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)