Skip to content

Commit b4a2f5b

Browse files
committed
feat: expose webview url as serialised field
1 parent f275a1f commit b4a2f5b

File tree

2 files changed

+26
-21
lines changed

2 files changed

+26
-21
lines changed

src/Packages/Passport/Runtime/Scripts/Private/UI/MacOSPassportWebView.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ private async UniTaskVoid InitializeAsync(PassportWebViewConfig config)
8181
// Create WebView prefab and parent to Canvas
8282
_webViewPrefab = CanvasWebViewPrefab.Instantiate();
8383
_webViewPrefab.Native2DModeEnabled = false; // Use standard mode for better desktop compatibility
84-
84+
8585
// Set higher resolution for desktop - MacOS can handle larger textures
8686
_webViewPrefab.Resolution = 1.5f; // 1.5px per Unity unit for crisp rendering
8787

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

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,29 @@ public class PassportUI : MonoBehaviour
7373
[Tooltip("Unity Event triggered when login fails (with error message)")]
7474
public UnityEvent<string> OnLoginFailure;
7575

76-
[Header("Debug Settings")]
76+
[Header("Debug Settings (Windows WebView Only)")]
77+
[Tooltip("Enable remote debugging for the Windows WebView (Volt Unity Web Browser). Not used on other platforms.")]
7778
public bool enableRemoteDebugging = false;
79+
[Tooltip("Port for remote debugging on Windows WebView (Volt Unity Web Browser). Not used on other platforms.")]
7880
public uint remoteDebuggingPort = 9222;
7981

80-
[Header("Cache Settings")]
82+
[Header("Cache Settings (Windows WebView Only)")]
83+
[Tooltip("Clear WebView cache on login for Windows WebView (Volt Unity Web Browser). Not used on other platforms.")]
8184
public bool clearCacheOnLogin = true;
8285

86+
[Header("WebView Settings")]
87+
[Tooltip("URL to load in the WebView for authentication.")]
88+
[SerializeField] private string webViewUrl = "http://localhost:3001";
89+
90+
/// <summary>
91+
/// Gets or sets the URL to load in the WebView for authentication
92+
/// </summary>
93+
public string WebViewUrl
94+
{
95+
get => webViewUrl;
96+
set => webViewUrl = value;
97+
}
98+
8399
// Cross-platform WebView abstraction
84100
private IPassportWebView webView;
85101

@@ -293,7 +309,7 @@ private async void HandleLoginData(string jsonData)
293309

294310
if (loginSuccess)
295311
{
296-
PassportLogger.Info($"{TAG} Login successful!");
312+
PassportLogger.Info($"{TAG} Login successful!");
297313

298314
// Trigger events
299315
OnLoginSuccess?.Invoke();
@@ -305,7 +321,7 @@ private async void HandleLoginData(string jsonData)
305321
else
306322
{
307323
string errorMessage = "Login failed - authentication was not completed";
308-
PassportLogger.Error($"{TAG} {errorMessage}");
324+
PassportLogger.Error($"{TAG} {errorMessage}");
309325

310326
// Trigger failure events
311327
OnLoginFailure?.Invoke(errorMessage);
@@ -382,7 +398,7 @@ public async UniTask<bool> ShowLoginUI()
382398
PassportLogger.Info($"{TAG} Passport bridge ready - waiting for login form submission");
383399

384400
// CRITICAL: Initialize deep link system for OAuth callback handling
385-
PassportLogger.Info($"{TAG} 🔗 Initializing deep link system for OAuth callbacks");
401+
PassportLogger.Info($"{TAG} Initializing deep link system for OAuth callbacks");
386402
#if UNITY_STANDALONE_WIN || (UNITY_ANDROID && UNITY_EDITOR_WIN) || (UNITY_IPHONE && UNITY_EDITOR_WIN)
387403
try
388404
{
@@ -396,7 +412,7 @@ public async UniTask<bool> ShowLoginUI()
396412
// Initialize deep link system with the redirect URI and PassportImpl's callback
397413
var redirectUri = "immutablerunner://callback";
398414
WindowsDeepLink.Initialise(redirectUri, passportImpl.OnDeepLinkActivated);
399-
PassportLogger.Info($"{TAG} Deep link system initialized for protocol: {redirectUri}");
415+
PassportLogger.Info($"{TAG} Deep link system initialized for protocol: {redirectUri}");
400416
}
401417
else
402418
{
@@ -409,22 +425,11 @@ public async UniTask<bool> ShowLoginUI()
409425
}
410426
#endif
411427

412-
// TESTING: Load local test page instead of auth URL
413-
PassportLogger.Info($"{TAG} 🧪 Loading local test page for development");
414-
string testPageUrl = "http://localhost:3001";
415-
PassportLogger.Info($"{TAG} Test page URL: {testPageUrl}");
416-
417-
// Show the WebView
418428
webView.Show();
419429
PassportLogger.Info($"{TAG} WebView shown");
420430

421-
// Navigate to test page
422-
webView.LoadUrl(testPageUrl);
423-
PassportLogger.Info($"{TAG} Navigated to test page: {testPageUrl}");
424-
425-
// Test page loaded for development
426-
PassportLogger.Info($"{TAG} 🧪 Test page loaded in WebView for development and testing.");
427-
PassportLogger.Info($"{TAG} Login data will be captured and logged from the test page.");
431+
webView.LoadUrl(webViewUrl);
432+
PassportLogger.Info($"{TAG} Navigated to configured URL: {webViewUrl}");
428433

429434
// Return true since we successfully started the OAuth flow
430435
// The actual authentication completion is handled by the deep link system
@@ -457,7 +462,7 @@ public void HideLoginUI(bool logMessage = true)
457462
if (bridgeWebViewGameObject != null && !bridgeWebViewGameObject.activeSelf)
458463
{
459464
bridgeWebViewGameObject.SetActive(true);
460-
PassportLogger.Info($"{TAG} Re-enabled bridge WebView {bridgeWebViewGameObject.name} - UI WebView is now hidden");
465+
PassportLogger.Info($"{TAG} Re-enabled bridge WebView {bridgeWebViewGameObject.name} - UI WebView is now hidden");
461466
bridgeWebViewGameObject = null; // Clear reference
462467
}
463468

0 commit comments

Comments
 (0)