From 04a8e8fdf7f69c05ce94902c8bd8bdae7583292e Mon Sep 17 00:00:00 2001 From: ImmutableJeffrey Date: Thu, 4 Sep 2025 17:43:56 +1000 Subject: [PATCH 1/6] feat: add vuplex webview for android (#3956) --- .../Immutable.Passport.Runtime.Private.asmdef | 3 +- .../Private/UI/AndroidPassportWebView.cs | 2 +- .../Private/UI/AndroidVuplexWebView.cs | 171 ++++++++++++++++++ .../Private/UI/AndroidVuplexWebView.cs.meta | 2 + .../Runtime/Scripts/Public/PassportUI.cs | 2 +- 5 files changed, 177 insertions(+), 3 deletions(-) create mode 100644 src/Packages/Passport/Runtime/Scripts/Private/UI/AndroidVuplexWebView.cs create mode 100644 src/Packages/Passport/Runtime/Scripts/Private/UI/AndroidVuplexWebView.cs.meta diff --git a/src/Packages/Passport/Runtime/Scripts/Private/Immutable.Passport.Runtime.Private.asmdef b/src/Packages/Passport/Runtime/Scripts/Private/Immutable.Passport.Runtime.Private.asmdef index 289b573bb..5ca03f58a 100644 --- a/src/Packages/Passport/Runtime/Scripts/Private/Immutable.Passport.Runtime.Private.asmdef +++ b/src/Packages/Passport/Runtime/Scripts/Private/Immutable.Passport.Runtime.Private.asmdef @@ -6,7 +6,8 @@ "UniTask", "Immutable.Browser.Core", "Immutable.Browser.Gree", - "Immutable.Passport.Core.Logging" + "Immutable.Passport.Core.Logging", + "Vuplex.WebView" ], "includePlatforms": [ "Android", diff --git a/src/Packages/Passport/Runtime/Scripts/Private/UI/AndroidPassportWebView.cs b/src/Packages/Passport/Runtime/Scripts/Private/UI/AndroidPassportWebView.cs index 49230e97c..662f2397f 100644 --- a/src/Packages/Passport/Runtime/Scripts/Private/UI/AndroidPassportWebView.cs +++ b/src/Packages/Passport/Runtime/Scripts/Private/UI/AndroidPassportWebView.cs @@ -248,7 +248,7 @@ private void CreateWebViewObject() UnityEngine.Object.DontDestroyOnLoad(webViewGameObject); // Add WebViewObject component - webViewObject = webViewGameObject.AddComponent(); + webViewObject = new WebViewObject(); PassportLogger.Info($"{TAG} Gree WebViewObject created successfully"); } diff --git a/src/Packages/Passport/Runtime/Scripts/Private/UI/AndroidVuplexWebView.cs b/src/Packages/Passport/Runtime/Scripts/Private/UI/AndroidVuplexWebView.cs new file mode 100644 index 000000000..2836c113c --- /dev/null +++ b/src/Packages/Passport/Runtime/Scripts/Private/UI/AndroidVuplexWebView.cs @@ -0,0 +1,171 @@ +using System; +using System.Collections.Generic; +using Cysharp.Threading.Tasks; +using UnityEngine; +using UnityEngine.UI; +using Immutable.Passport.Core.Logging; +using Vuplex.WebView; + +namespace Immutable.Passport +{ + public class AndroidVuplexWebView : IPassportWebView + { + private const string TAG = "[AndroidWebView]"; + private CanvasWebViewPrefab _webViewPrefab; + private readonly Dictionary> _jsHandlers = new Dictionary>(); + private readonly RawImage _canvasReference; + private bool _isInitialized = false; + + public event Action OnJavaScriptMessage; + public event Action OnLoadFinished; + public event Action OnLoadStarted; + + // Safe access - check initialization + public bool IsVisible => _webViewPrefab?.Visible ?? false; + public string CurrentUrl => _webViewPrefab?.WebView?.Url ?? ""; + + public AndroidVuplexWebView(RawImage canvasReference) + { + _canvasReference = canvasReference ?? throw new ArgumentNullException(nameof(canvasReference)); + } + + public void Initialize(PassportWebViewConfig config) + { + if (_isInitialized) + { + PassportLogger.Warn($"{TAG} Already initialized, skipping"); + return; + } + + try + { + PassportLogger.Info($"{TAG} Initializing Vuplex WebView..."); + + // Start async initialization but don't wait + InitializeAsync(config).Forget(); + } + catch (Exception ex) + { + PassportLogger.Error($"{TAG} Failed to initialize: {ex.Message}"); + throw; + } + } + + private async UniTaskVoid InitializeAsync(PassportWebViewConfig config) + { + try + { + // Create WebView prefab and parent to Canvas + _webViewPrefab = CanvasWebViewPrefab.Instantiate(); + _webViewPrefab.Native2DModeEnabled = true; + + // Must be child of Canvas for Vuplex to work + _webViewPrefab.transform.SetParent(_canvasReference.canvas.transform, false); + + // Set up full-screen layout for Native 2D Mode + var rect = _webViewPrefab.GetComponent(); + rect.anchorMin = Vector2.zero; + rect.anchorMax = Vector2.one; + rect.offsetMin = rect.offsetMax = Vector2.zero; + + // Wait for WebView initialization + await _webViewPrefab.WaitUntilInitialized(); + + // Setup event handlers + _webViewPrefab.WebView.LoadProgressChanged += (s, e) => + { + if (e.Type == ProgressChangeType.Started) + { + OnLoadStarted?.Invoke(); + } + else if (e.Type == ProgressChangeType.Finished) + { + OnLoadFinished?.Invoke(); + } + }; + _webViewPrefab.WebView.MessageEmitted += (s, e) => + { + foreach (var h in _jsHandlers) + { + if (e.Value.StartsWith($"{h.Key}:")) + { + h.Value?.Invoke(e.Value.Substring(h.Key.Length + 1)); + return; + } + } + + OnJavaScriptMessage?.Invoke(e.Value); + }; + _webViewPrefab.WebView.LoadFailed += (s, e) => PassportLogger.Warn($"{TAG} Load failed: {e.NativeErrorCode} for {e.Url}"); + + _isInitialized = true; + PassportLogger.Info($"{TAG} Vuplex WebView initialized successfully"); + } + catch (Exception ex) + { + PassportLogger.Error($"{TAG} Failed to initialize async: {ex.Message}"); + throw; + } + } + + public void LoadUrl(string url) + { + if (!_isInitialized || _webViewPrefab?.WebView == null) + { + PassportLogger.Error($"{TAG} Cannot load URL - WebView not initialized"); + return; + } + + _webViewPrefab.WebView.LoadUrl(url); + } + + public void Show() + { + if (_webViewPrefab != null) + { + _webViewPrefab.Visible = true; + } + } + + public void Hide() + { + if (_webViewPrefab != null) + { + _webViewPrefab.Visible = false; + } + } + + public void ExecuteJavaScript(string js) + { + if (!_isInitialized || _webViewPrefab?.WebView == null) + { + PassportLogger.Error($"{TAG} Cannot execute JavaScript - WebView not initialized"); + return; + } + + _webViewPrefab.WebView.ExecuteJavaScript(js); + } + + public void RegisterJavaScriptMethod(string methodName, Action handler) + { + _jsHandlers[methodName] = handler; + + if (_isInitialized && _webViewPrefab?.WebView != null) + { + ExecuteJavaScript($"window.{methodName}=d=>window.vuplex?.postMessage('{methodName}:'+(typeof d==='object'?JSON.stringify(d):d))"); + } + } + + public void Dispose() + { + if (_webViewPrefab != null) + { + _webViewPrefab.Destroy(); + _webViewPrefab = null; + } + + _jsHandlers.Clear(); + _isInitialized = false; + } + } +} \ No newline at end of file diff --git a/src/Packages/Passport/Runtime/Scripts/Private/UI/AndroidVuplexWebView.cs.meta b/src/Packages/Passport/Runtime/Scripts/Private/UI/AndroidVuplexWebView.cs.meta new file mode 100644 index 000000000..e22e27500 --- /dev/null +++ b/src/Packages/Passport/Runtime/Scripts/Private/UI/AndroidVuplexWebView.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: ee900f6b1f028034f8399f83385c3a44 \ No newline at end of file diff --git a/src/Packages/Passport/Runtime/Scripts/Public/PassportUI.cs b/src/Packages/Passport/Runtime/Scripts/Public/PassportUI.cs index 349b1eb37..0cf1b64a4 100644 --- a/src/Packages/Passport/Runtime/Scripts/Public/PassportUI.cs +++ b/src/Packages/Passport/Runtime/Scripts/Public/PassportUI.cs @@ -202,7 +202,7 @@ private IPassportWebView CreatePlatformWebView() return new iOSPassportWebView(rawImage, this); #elif UNITY_ANDROID PassportLogger.Info($"{TAG} Creating Android WebView"); - return new AndroidPassportWebView(rawImage, this); + return new AndroidVuplexWebView(rawImage); #elif UNITY_STANDALONE_OSX PassportLogger.Info($"{TAG} Creating macOS WebView (WKWebView)"); // TODO: Implement macOS WebView From be29c5a60c65490f8bb33fb792066e20ceb2746b Mon Sep 17 00:00:00 2001 From: ImmutableJeffrey Date: Mon, 8 Sep 2025 09:29:19 +1000 Subject: [PATCH 2/6] fix: linting errors --- .../Runtime/Scripts/Private/UI/AndroidPassportWebView.cs | 8 ++++---- .../Runtime/Scripts/Private/UI/WindowsPassportWebView.cs | 4 ++-- .../Runtime/Scripts/Private/UI/iOSPassportWebView.cs | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Packages/Passport/Runtime/Scripts/Private/UI/AndroidPassportWebView.cs b/src/Packages/Passport/Runtime/Scripts/Private/UI/AndroidPassportWebView.cs index 662f2397f..8d0d15a99 100644 --- a/src/Packages/Passport/Runtime/Scripts/Private/UI/AndroidPassportWebView.cs +++ b/src/Packages/Passport/Runtime/Scripts/Private/UI/AndroidPassportWebView.cs @@ -237,7 +237,7 @@ public void Dispose() } } - #region Private Implementation + #region Private Implementation private void CreateWebViewObject() { @@ -276,9 +276,9 @@ private void ConfigureWebView() PassportLogger.Info($"{TAG} Gree WebView configured successfully"); } - #endregion + #endregion - #region WebView Event Handlers + #region WebView Event Handlers private void OnWebViewMessage(string message) { @@ -326,7 +326,7 @@ private void OnWebViewLog(string message) PassportLogger.Debug($"{TAG} WebView console log: {message}"); } - #endregion + #endregion } #endif } diff --git a/src/Packages/Passport/Runtime/Scripts/Private/UI/WindowsPassportWebView.cs b/src/Packages/Passport/Runtime/Scripts/Private/UI/WindowsPassportWebView.cs index da60cf90e..d8afe9b90 100644 --- a/src/Packages/Passport/Runtime/Scripts/Private/UI/WindowsPassportWebView.cs +++ b/src/Packages/Passport/Runtime/Scripts/Private/UI/WindowsPassportWebView.cs @@ -355,7 +355,7 @@ public void Dispose() } } - #region Private Implementation + #region Private Implementation private void CreateUWBInstance() { @@ -689,7 +689,7 @@ private bool IsPortAvailable(int port) } } - #endregion + #endregion } #endif } diff --git a/src/Packages/Passport/Runtime/Scripts/Private/UI/iOSPassportWebView.cs b/src/Packages/Passport/Runtime/Scripts/Private/UI/iOSPassportWebView.cs index 3c7320792..119aeecfe 100644 --- a/src/Packages/Passport/Runtime/Scripts/Private/UI/iOSPassportWebView.cs +++ b/src/Packages/Passport/Runtime/Scripts/Private/UI/iOSPassportWebView.cs @@ -236,7 +236,7 @@ public void Dispose() } } - #region Private Implementation + #region Private Implementation private void CreateWebViewObject() { @@ -279,9 +279,9 @@ private void ConfigureWebView() PassportLogger.Info($"{TAG} Gree WebView configured successfully"); } - #endregion + #endregion - #region WebView Event Handlers + #region WebView Event Handlers private void OnWebViewMessage(string message) { @@ -329,7 +329,7 @@ private void OnWebViewLog(string message) PassportLogger.Debug($"{TAG} WebView console log: {message}"); } - #endregion + #endregion } #endif } From 8e79a2a1a1a702bb319d0e42ee0a7b01db0431ed Mon Sep 17 00:00:00 2001 From: ImmutableJeffrey Date: Mon, 8 Sep 2025 12:27:35 +1000 Subject: [PATCH 3/6] fix: android pr checks --- .../Private/UI/AndroidVuplexWebView.cs | 50 ++++++++++++++++--- 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/src/Packages/Passport/Runtime/Scripts/Private/UI/AndroidVuplexWebView.cs b/src/Packages/Passport/Runtime/Scripts/Private/UI/AndroidVuplexWebView.cs index 2836c113c..a90d43cf3 100644 --- a/src/Packages/Passport/Runtime/Scripts/Private/UI/AndroidVuplexWebView.cs +++ b/src/Packages/Passport/Runtime/Scripts/Private/UI/AndroidVuplexWebView.cs @@ -1,28 +1,45 @@ +#nullable enable using System; using System.Collections.Generic; using Cysharp.Threading.Tasks; using UnityEngine; using UnityEngine.UI; using Immutable.Passport.Core.Logging; + + #if UNITY_ANDROID && !UNITY_EDITOR && VUPLEX_AVAILABLE && VUPLEX_AVAILABLE && VUPLEX_AVAILABLE using Vuplex.WebView; +#endif namespace Immutable.Passport { + /// + /// Android implementation of IPassportWebView using Vuplex WebView + /// Provides embedded WebView functionality within the Unity app (not external browser) + /// This is different from AndroidPassportWebView which uses external browser for auth flows + /// public class AndroidVuplexWebView : IPassportWebView { - private const string TAG = "[AndroidWebView]"; - private CanvasWebViewPrefab _webViewPrefab; + private const string TAG = "[AndroidVuplexWebView]"; + + #if UNITY_ANDROID && !UNITY_EDITOR && VUPLEX_AVAILABLE && VUPLEX_AVAILABLE && VUPLEX_AVAILABLE + private CanvasWebViewPrefab? _webViewPrefab; +#endif private readonly Dictionary> _jsHandlers = new Dictionary>(); private readonly RawImage _canvasReference; private bool _isInitialized = false; - public event Action OnJavaScriptMessage; - public event Action OnLoadFinished; - public event Action OnLoadStarted; + public event Action? OnJavaScriptMessage; + public event Action? OnLoadFinished; + public event Action? OnLoadStarted; // Safe access - check initialization + #if UNITY_ANDROID && !UNITY_EDITOR && VUPLEX_AVAILABLE && VUPLEX_AVAILABLE && VUPLEX_AVAILABLE public bool IsVisible => _webViewPrefab?.Visible ?? false; public string CurrentUrl => _webViewPrefab?.WebView?.Url ?? ""; +#else + public bool IsVisible => false; + public string CurrentUrl => ""; +#endif public AndroidVuplexWebView(RawImage canvasReference) { @@ -37,6 +54,7 @@ public void Initialize(PassportWebViewConfig config) return; } + #if UNITY_ANDROID && !UNITY_EDITOR && VUPLEX_AVAILABLE && VUPLEX_AVAILABLE try { PassportLogger.Info($"{TAG} Initializing Vuplex WebView..."); @@ -49,8 +67,13 @@ public void Initialize(PassportWebViewConfig config) PassportLogger.Error($"{TAG} Failed to initialize: {ex.Message}"); throw; } +#else + PassportLogger.Warn($"{TAG} Vuplex WebView is only supported on Android builds, not in editor"); + _isInitialized = true; +#endif } + #if UNITY_ANDROID && !UNITY_EDITOR && VUPLEX_AVAILABLE && VUPLEX_AVAILABLE private async UniTaskVoid InitializeAsync(PassportWebViewConfig config) { try @@ -107,9 +130,11 @@ private async UniTaskVoid InitializeAsync(PassportWebViewConfig config) throw; } } +#endif public void LoadUrl(string url) { + #if UNITY_ANDROID && !UNITY_EDITOR && VUPLEX_AVAILABLE && VUPLEX_AVAILABLE if (!_isInitialized || _webViewPrefab?.WebView == null) { PassportLogger.Error($"{TAG} Cannot load URL - WebView not initialized"); @@ -117,26 +142,34 @@ public void LoadUrl(string url) } _webViewPrefab.WebView.LoadUrl(url); +#else + PassportLogger.Warn($"{TAG} LoadUrl not supported in editor mode"); +#endif } public void Show() { + #if UNITY_ANDROID && !UNITY_EDITOR && VUPLEX_AVAILABLE && VUPLEX_AVAILABLE if (_webViewPrefab != null) { _webViewPrefab.Visible = true; } +#endif } public void Hide() { + #if UNITY_ANDROID && !UNITY_EDITOR && VUPLEX_AVAILABLE && VUPLEX_AVAILABLE if (_webViewPrefab != null) { _webViewPrefab.Visible = false; } +#endif } public void ExecuteJavaScript(string js) { + #if UNITY_ANDROID && !UNITY_EDITOR && VUPLEX_AVAILABLE && VUPLEX_AVAILABLE if (!_isInitialized || _webViewPrefab?.WebView == null) { PassportLogger.Error($"{TAG} Cannot execute JavaScript - WebView not initialized"); @@ -144,28 +177,33 @@ public void ExecuteJavaScript(string js) } _webViewPrefab.WebView.ExecuteJavaScript(js); +#endif } public void RegisterJavaScriptMethod(string methodName, Action handler) { _jsHandlers[methodName] = handler; + #if UNITY_ANDROID && !UNITY_EDITOR && VUPLEX_AVAILABLE && VUPLEX_AVAILABLE if (_isInitialized && _webViewPrefab?.WebView != null) { ExecuteJavaScript($"window.{methodName}=d=>window.vuplex?.postMessage('{methodName}:'+(typeof d==='object'?JSON.stringify(d):d))"); } +#endif } public void Dispose() { + #if UNITY_ANDROID && !UNITY_EDITOR && VUPLEX_AVAILABLE && VUPLEX_AVAILABLE if (_webViewPrefab != null) { _webViewPrefab.Destroy(); _webViewPrefab = null; } +#endif _jsHandlers.Clear(); _isInitialized = false; } } -} \ No newline at end of file +} From cedaa6a17d25396072a3e02e1fa173b01017f988 Mon Sep 17 00:00:00 2001 From: ImmutableJeffrey Date: Mon, 8 Sep 2025 12:53:14 +1000 Subject: [PATCH 4/6] fix: linting errors --- .../Private/UI/AndroidVuplexWebView.cs | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Packages/Passport/Runtime/Scripts/Private/UI/AndroidVuplexWebView.cs b/src/Packages/Passport/Runtime/Scripts/Private/UI/AndroidVuplexWebView.cs index a90d43cf3..526a4bf8e 100644 --- a/src/Packages/Passport/Runtime/Scripts/Private/UI/AndroidVuplexWebView.cs +++ b/src/Packages/Passport/Runtime/Scripts/Private/UI/AndroidVuplexWebView.cs @@ -6,7 +6,7 @@ using UnityEngine.UI; using Immutable.Passport.Core.Logging; - #if UNITY_ANDROID && !UNITY_EDITOR && VUPLEX_AVAILABLE && VUPLEX_AVAILABLE && VUPLEX_AVAILABLE +#if UNITY_ANDROID && !UNITY_EDITOR && VUPLEX_AVAILABLE && VUPLEX_AVAILABLE && VUPLEX_AVAILABLE using Vuplex.WebView; #endif @@ -20,8 +20,8 @@ namespace Immutable.Passport public class AndroidVuplexWebView : IPassportWebView { private const string TAG = "[AndroidVuplexWebView]"; - - #if UNITY_ANDROID && !UNITY_EDITOR && VUPLEX_AVAILABLE && VUPLEX_AVAILABLE && VUPLEX_AVAILABLE + +#if UNITY_ANDROID && !UNITY_EDITOR && VUPLEX_AVAILABLE && VUPLEX_AVAILABLE && VUPLEX_AVAILABLE private CanvasWebViewPrefab? _webViewPrefab; #endif private readonly Dictionary> _jsHandlers = new Dictionary>(); @@ -33,7 +33,7 @@ public class AndroidVuplexWebView : IPassportWebView public event Action? OnLoadStarted; // Safe access - check initialization - #if UNITY_ANDROID && !UNITY_EDITOR && VUPLEX_AVAILABLE && VUPLEX_AVAILABLE && VUPLEX_AVAILABLE +#if UNITY_ANDROID && !UNITY_EDITOR && VUPLEX_AVAILABLE && VUPLEX_AVAILABLE && VUPLEX_AVAILABLE public bool IsVisible => _webViewPrefab?.Visible ?? false; public string CurrentUrl => _webViewPrefab?.WebView?.Url ?? ""; #else @@ -54,7 +54,7 @@ public void Initialize(PassportWebViewConfig config) return; } - #if UNITY_ANDROID && !UNITY_EDITOR && VUPLEX_AVAILABLE && VUPLEX_AVAILABLE +#if UNITY_ANDROID && !UNITY_EDITOR && VUPLEX_AVAILABLE && VUPLEX_AVAILABLE try { PassportLogger.Info($"{TAG} Initializing Vuplex WebView..."); @@ -73,7 +73,7 @@ public void Initialize(PassportWebViewConfig config) #endif } - #if UNITY_ANDROID && !UNITY_EDITOR && VUPLEX_AVAILABLE && VUPLEX_AVAILABLE +#if UNITY_ANDROID && !UNITY_EDITOR && VUPLEX_AVAILABLE && VUPLEX_AVAILABLE private async UniTaskVoid InitializeAsync(PassportWebViewConfig config) { try @@ -134,7 +134,7 @@ private async UniTaskVoid InitializeAsync(PassportWebViewConfig config) public void LoadUrl(string url) { - #if UNITY_ANDROID && !UNITY_EDITOR && VUPLEX_AVAILABLE && VUPLEX_AVAILABLE +#if UNITY_ANDROID && !UNITY_EDITOR && VUPLEX_AVAILABLE && VUPLEX_AVAILABLE if (!_isInitialized || _webViewPrefab?.WebView == null) { PassportLogger.Error($"{TAG} Cannot load URL - WebView not initialized"); @@ -149,7 +149,7 @@ public void LoadUrl(string url) public void Show() { - #if UNITY_ANDROID && !UNITY_EDITOR && VUPLEX_AVAILABLE && VUPLEX_AVAILABLE +#if UNITY_ANDROID && !UNITY_EDITOR && VUPLEX_AVAILABLE && VUPLEX_AVAILABLE if (_webViewPrefab != null) { _webViewPrefab.Visible = true; @@ -159,7 +159,7 @@ public void Show() public void Hide() { - #if UNITY_ANDROID && !UNITY_EDITOR && VUPLEX_AVAILABLE && VUPLEX_AVAILABLE +#if UNITY_ANDROID && !UNITY_EDITOR && VUPLEX_AVAILABLE && VUPLEX_AVAILABLE if (_webViewPrefab != null) { _webViewPrefab.Visible = false; @@ -169,7 +169,7 @@ public void Hide() public void ExecuteJavaScript(string js) { - #if UNITY_ANDROID && !UNITY_EDITOR && VUPLEX_AVAILABLE && VUPLEX_AVAILABLE +#if UNITY_ANDROID && !UNITY_EDITOR && VUPLEX_AVAILABLE && VUPLEX_AVAILABLE if (!_isInitialized || _webViewPrefab?.WebView == null) { PassportLogger.Error($"{TAG} Cannot execute JavaScript - WebView not initialized"); @@ -184,7 +184,7 @@ public void RegisterJavaScriptMethod(string methodName, Action handler) { _jsHandlers[methodName] = handler; - #if UNITY_ANDROID && !UNITY_EDITOR && VUPLEX_AVAILABLE && VUPLEX_AVAILABLE +#if UNITY_ANDROID && !UNITY_EDITOR && VUPLEX_AVAILABLE && VUPLEX_AVAILABLE if (_isInitialized && _webViewPrefab?.WebView != null) { ExecuteJavaScript($"window.{methodName}=d=>window.vuplex?.postMessage('{methodName}:'+(typeof d==='object'?JSON.stringify(d):d))"); @@ -194,7 +194,7 @@ public void RegisterJavaScriptMethod(string methodName, Action handler) public void Dispose() { - #if UNITY_ANDROID && !UNITY_EDITOR && VUPLEX_AVAILABLE && VUPLEX_AVAILABLE +#if UNITY_ANDROID && !UNITY_EDITOR && VUPLEX_AVAILABLE && VUPLEX_AVAILABLE if (_webViewPrefab != null) { _webViewPrefab.Destroy(); From 1a6ae2e709344ade393c2b1c54111de1b3ac3dab Mon Sep 17 00:00:00 2001 From: ImmutableJeffrey Date: Mon, 8 Sep 2025 13:38:57 +1000 Subject: [PATCH 5/6] fix: ios build errors --- .../Runtime/Scripts/Private/UI/iOSPassportWebView.cs | 9 +++------ src/Packages/Passport/Runtime/Scripts/Public/Passport.cs | 1 + .../Passport/Runtime/Scripts/Public/PassportUI.cs | 3 --- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/Packages/Passport/Runtime/Scripts/Private/UI/iOSPassportWebView.cs b/src/Packages/Passport/Runtime/Scripts/Private/UI/iOSPassportWebView.cs index 119aeecfe..64daa8ef3 100644 --- a/src/Packages/Passport/Runtime/Scripts/Private/UI/iOSPassportWebView.cs +++ b/src/Packages/Passport/Runtime/Scripts/Private/UI/iOSPassportWebView.cs @@ -3,13 +3,13 @@ using UnityEngine.UI; using Immutable.Passport.Core.Logging; -#if UNITY_IOS && !UNITY_EDITOR +#if UNITY_IOS || UNITY_EDITOR_OSX using Immutable.Browser.Gree; #endif namespace Immutable.Passport { -#if UNITY_IOS && !UNITY_EDITOR +#if UNITY_IOS || UNITY_EDITOR_OSX /// /// iOS implementation of IPassportWebView using Gree WebView (WKWebView) /// Wraps Gree WebViewObject in a clean, platform-agnostic interface @@ -246,8 +246,7 @@ private void CreateWebViewObject() webViewGameObject = new GameObject("PassportUI_iOS_WebView"); UnityEngine.Object.DontDestroyOnLoad(webViewGameObject); - // Add WebViewObject component - webViewObject = webViewGameObject.AddComponent(); + webViewObject = new WebViewObject(); PassportLogger.Info($"{TAG} Gree WebViewObject created successfully"); } @@ -266,8 +265,6 @@ private void ConfigureWebView() ); // Configure WebView settings - webViewObject.SetMargins(0, 0, 0, 0); // Full screen - webViewObject.SetVisibility(false); // Start hidden // Clear cache if requested if (config.ClearCacheOnInit) diff --git a/src/Packages/Passport/Runtime/Scripts/Public/Passport.cs b/src/Packages/Passport/Runtime/Scripts/Public/Passport.cs index 83fc4e270..0d667317b 100644 --- a/src/Packages/Passport/Runtime/Scripts/Public/Passport.cs +++ b/src/Packages/Passport/Runtime/Scripts/Public/Passport.cs @@ -237,6 +237,7 @@ private async UniTask Initialise( #elif (UNITY_ANDROID && !UNITY_EDITOR_WIN) || (UNITY_IPHONE && !UNITY_EDITOR_WIN) || UNITY_STANDALONE_OSX || UNITY_WEBGL // Initialise default browser client for Android, iOS, and macOS _webBrowserClient = new GreeBrowserClient(); + await UniTask.CompletedTask; #else throw new PassportException("Platform not supported"); #endif diff --git a/src/Packages/Passport/Runtime/Scripts/Public/PassportUI.cs b/src/Packages/Passport/Runtime/Scripts/Public/PassportUI.cs index 0cf1b64a4..f2b2f033e 100644 --- a/src/Packages/Passport/Runtime/Scripts/Public/PassportUI.cs +++ b/src/Packages/Passport/Runtime/Scripts/Public/PassportUI.cs @@ -83,7 +83,6 @@ public class PassportUI : MonoBehaviour private RawImage rawImage; // Login completion source removed - OAuth handled by external browser private bool isInitialized = false; - private bool pointerEnterTriggered = false; private GameObject bridgeWebViewGameObject; // Input management @@ -459,8 +458,6 @@ public void HideLoginUI(bool logMessage = true) bridgeWebViewGameObject = null; // Clear reference } - // Reset pointer enter flag for next login - pointerEnterTriggered = false; } /// From a7ac7f948811adb104a0190de14b82ba8634700a Mon Sep 17 00:00:00 2001 From: ImmutableJeffrey Date: Mon, 8 Sep 2025 19:08:11 +1000 Subject: [PATCH 6/6] fix: test fail on windows --- sample/Assets/Scripts/Passport/AuthenticatedSceneManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sample/Assets/Scripts/Passport/AuthenticatedSceneManager.cs b/sample/Assets/Scripts/Passport/AuthenticatedSceneManager.cs index ec47df36e..262029ffd 100644 --- a/sample/Assets/Scripts/Passport/AuthenticatedSceneManager.cs +++ b/sample/Assets/Scripts/Passport/AuthenticatedSceneManager.cs @@ -60,6 +60,6 @@ public static void NavigateToAuthenticatedScene() public static void NavigateToUnauthenticatedScene() { - UnityEngine.SceneManagement.SceneManager.LoadScene("InitialisationWithUI"); + UnityEngine.SceneManagement.SceneManager.LoadScene("UnauthenticatedScene"); } } \ No newline at end of file