Skip to content

Commit d4ab0ef

Browse files
committed
webgl
1 parent 1aa32d2 commit d4ab0ef

File tree

9 files changed

+38
-14
lines changed

9 files changed

+38
-14
lines changed

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

Lines changed: 1 addition & 1 deletion
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

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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ public async UniTask Init(string clientId, string environment, string redirectUr
9494
initRequest = JsonUtility.ToJson(request);
9595
}
9696

97+
PassportLogger.Debug($"{TAG} initRequest: " + initRequest);
9798
string response = await communicationsManager.Call(PassportFunction.INIT, initRequest);
9899
BrowserResponse initResponse = response.OptDeserializeObject<BrowserResponse>();
99100

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: 12 additions & 8 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,22 +181,26 @@ 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);
192+
// BrowserCommunicationsManager communicationsManager = new BrowserCommunicationsManager(webBrowserClient);
193+
194+
#if UNITY_WEBGL
195+
readySignalReceived = true;
196+
#else
193197
// Mark ready when browser is initialised and game bridge file is loaded
194-
communicationsManager.OnReady += () => readySignalReceived = true;
195-
198+
// communicationsManager.OnReady += () => readySignalReceived = true;
199+
#endif
196200
// Set up Passport implementation
197-
passportImpl = new PassportImpl(communicationsManager);
198-
// Subscribe to Passport authentication events
199-
passportImpl.OnAuthEvent += OnPassportAuthEvent;
201+
// passportImpl = new PassportImpl(communicationsManager);
202+
// // Subscribe to Passport authentication events
203+
// passportImpl.OnAuthEvent += OnPassportAuthEvent;
200204
}
201205
catch (Exception ex)
202206
{

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

Lines changed: 13 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
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,
@@ -34,6 +40,8 @@ public GreeBrowserClient()
3440

3541
private void InvokeOnPostMessageError(string id, string message)
3642
{
43+
PassportLogger.Info($"{TAG} InvokeOnPostMessageError: {message}");
44+
3745
if (OnPostMessageError != null)
3846
{
3947
OnPostMessageError.Invoke(id, message);
@@ -42,6 +50,8 @@ private void InvokeOnPostMessageError(string id, string message)
4250

4351
internal void InvokeOnAuthPostMessage(string message)
4452
{
53+
PassportLogger.Info($"{TAG} InvokeOnAuthPostMessage: {message}");
54+
4555
if (OnAuthPostMessage != null)
4656
{
4757
OnAuthPostMessage.Invoke(message);
@@ -50,6 +60,8 @@ internal void InvokeOnAuthPostMessage(string message)
5060

5161
internal void InvokeOnUnityPostMessage(string message)
5262
{
63+
PassportLogger.Info($"{TAG} InvokeOnUnityPostMessage: {message}");
64+
5365
if (OnUnityPostMessage != null)
5466
{
5567
OnUnityPostMessage.Invoke(message);

src/Packages/Passport/Runtime/ThirdParty/Gree/unity-webview.asmdef

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"Android",
1010
"Editor",
1111
"iOS",
12-
"macOSStandalone"
12+
"macOSStandalone",
13+
"WebGL"
1314
],
1415
"excludePlatforms": [],
1516
"allowUnsafeCode": false,

src/Packages/Passport/Runtime/ThirdParty/ImmutableBrowserCore/GameBridge.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public static class GameBridge
1111
private const string PASSPORT_PACKAGE_RESOURCES_DIRECTORY = "Packages/com.immutable.passport/Runtime/Resources";
1212
private const string ANDROID_DATA_DIRECTORY = "android_asset";
1313
private const string MAC_DATA_DIRECTORY = "/Resources/Data";
14+
private const string WEBGL_DIRECTORY = "/Passport";
1415
private const string MAC_EDITOR_RESOURCES_DIRECTORY = "Packages/com.immutable.passport/Runtime/Resources";
1516

1617
public static string GetFilePath()
@@ -32,6 +33,9 @@ public static string GetFilePath()
3233
#elif UNITY_EDITOR_WIN
3334
// Windows editor
3435
filePath = SCHEME_FILE + Path.GetFullPath($"{PASSPORT_PACKAGE_RESOURCES_DIRECTORY}{PASSPORT_HTML_FILE_NAME}");
36+
#elif UNITY_WEBGL
37+
// WebGL
38+
filePath = WEBGL_DIRECTORY + PASSPORT_HTML_FILE_NAME;
3539
#else
3640
filePath = SCHEME_FILE + Path.GetFullPath(Application.dataPath) + PASSPORT_DATA_DIRECTORY_NAME + PASSPORT_HTML_FILE_NAME;
3741
#endif

src/Packages/Passport/Runtime/ThirdParty/ImmutableBrowserCore/IWindowsWebBrowserClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN)
1+
#if UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN) || UNITY_WEBGL
22

33
using System.IO;
44
using UnityEngine;

0 commit comments

Comments
 (0)