Skip to content

Commit 0d2fc3c

Browse files
committed
Allow overriding redirect html
1 parent 4f53d12 commit 0d2fc3c

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed
0 Bytes
Binary file not shown.

Assets/Thirdweb/Runtime/Unity/Browser/CrossPlatformUnityBrowser.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,25 @@ public class CrossPlatformUnityBrowser : IThirdwebBrowser
99
{
1010
IThirdwebBrowser _unityBrowser;
1111

12-
public CrossPlatformUnityBrowser()
12+
public CrossPlatformUnityBrowser(string htmlOverride = null)
1313
{
14+
if (string.IsNullOrEmpty(htmlOverride) || string.IsNullOrWhiteSpace(htmlOverride))
15+
{
16+
htmlOverride = null;
17+
}
18+
1419
var go = new GameObject("WebGLInAppWalletBrowser");
1520

1621
#if UNITY_EDITOR
17-
_unityBrowser = new InAppWalletBrowser();
22+
_unityBrowser = new InAppWalletBrowser(htmlOverride);
1823
#elif UNITY_WEBGL
1924
_unityBrowser = go.AddComponent<WebGLInAppWalletBrowser>();
2025
#elif UNITY_ANDROID
2126
_unityBrowser = new AndroidBrowser();
2227
#elif UNITY_IOS
2328
_unityBrowser = new IOSBrowser();
2429
#else
25-
_unityBrowser = new InAppWalletBrowser();
30+
_unityBrowser = new InAppWalletBrowser(htmlOverride);
2631
#endif
2732
}
2833

Assets/Thirdweb/Runtime/Unity/ThirdwebManager.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,26 +134,38 @@ public WalletOptions(
134134
}
135135
}
136136

137+
[HelpURL("http://portal.thirdweb.com/unity/v5/thirdwebmanager")]
137138
public class ThirdwebManager : MonoBehaviour
138139
{
139140
[field: SerializeField, Header("Client Settings")]
141+
[Tooltip("API key for your Thirdweb project. Get your API key from https://thirdweb.com/create-api-key")]
140142
private string ClientId { get; set; }
141143

142144
[field: SerializeField]
145+
[Tooltip("Bundle ID of your Unity project. Default is Application.identifier. If not set, it will be generated using Application.companyName and Application.productName.")]
143146
private string BundleId { get; set; }
144147

145148
[field: SerializeField]
149+
[Tooltip("Initialize ThirdwebManager on Awake. Default is true. Set to false if you want to initialize manually.")]
146150
private bool InitializeOnAwake { get; set; } = true;
147151

148152
[field: SerializeField]
153+
[Tooltip("Enable or disable debug logs. Default is true.")]
149154
private bool ShowDebugLogs { get; set; } = true;
150155

151156
[field: SerializeField]
157+
[Tooltip("Opt out of usage analytics. This will disable tracking of wallet connection events and affect your dashboard stats.")]
152158
private bool OptOutUsageAnalytics { get; set; } = false;
153159

154160
[field: SerializeField, Header("WalletConnect Settings")]
161+
[Tooltip("Chain IDs supported by WalletConnect Wallet.")]
155162
private ulong[] SupportedChains { get; set; } = new ulong[] { 421614 };
156163

164+
[field: SerializeField, Header("Desktop OAuth Settings")]
165+
[Tooltip("HTML content to be displayed when redirecting to the OAuth provider. Leave empty to use the default page.")]
166+
[TextArea(3, 10)]
167+
private string RedirectPageHtmlOverride;
168+
157169
public ThirdwebClient Client { get; private set; }
158170

159171
public IThirdwebWallet ActiveWallet { get; private set; }
@@ -355,7 +367,7 @@ public async Task<IThirdwebWallet> ConnectWallet(WalletOptions walletOptions)
355367
isMobile: Application.isMobilePlatform,
356368
browserOpenAction: (url) => Application.OpenURL(url),
357369
mobileRedirectScheme: BundleId + "://",
358-
browser: new CrossPlatformUnityBrowser()
370+
browser: new CrossPlatformUnityBrowser(RedirectPageHtmlOverride)
359371
);
360372
}
361373
}
@@ -393,7 +405,7 @@ public async Task<IThirdwebWallet> ConnectWallet(WalletOptions walletOptions)
393405
isMobile: Application.isMobilePlatform,
394406
browserOpenAction: (url) => Application.OpenURL(url),
395407
mobileRedirectScheme: BundleId + "://",
396-
browser: new CrossPlatformUnityBrowser()
408+
browser: new CrossPlatformUnityBrowser(RedirectPageHtmlOverride)
397409
);
398410
}
399411
}
@@ -470,7 +482,7 @@ public async Task<List<LinkedAccount>> LinkAccount(InAppWallet mainWallet, InApp
470482
isMobile: Application.isMobilePlatform,
471483
browserOpenAction: (url) => Application.OpenURL(url),
472484
mobileRedirectScheme: BundleId + "://",
473-
browser: new CrossPlatformUnityBrowser(),
485+
browser: new CrossPlatformUnityBrowser(RedirectPageHtmlOverride),
474486
chainId: chainId,
475487
jwt: jwtOrPayload,
476488
payload: jwtOrPayload
@@ -485,7 +497,7 @@ public async Task<List<LinkedAccount>> LinkAccount(EcosystemWallet mainWallet, E
485497
isMobile: Application.isMobilePlatform,
486498
browserOpenAction: (url) => Application.OpenURL(url),
487499
mobileRedirectScheme: BundleId + "://",
488-
browser: new CrossPlatformUnityBrowser(),
500+
browser: new CrossPlatformUnityBrowser(RedirectPageHtmlOverride),
489501
chainId: chainId,
490502
jwt: jwtOrPayload,
491503
payload: jwtOrPayload

0 commit comments

Comments
 (0)