Skip to content

Commit f88f81f

Browse files
committed
Fix WebGL Duplicate Popup State
1 parent c29b84b commit f88f81f

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

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

+14-3
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,23 @@ public CrossPlatformUnityBrowser(string htmlOverride = null)
1616
htmlOverride = null;
1717
}
1818

19-
var go = new GameObject("WebGLInAppWalletBrowser");
20-
2119
#if UNITY_EDITOR
2220
_unityBrowser = new InAppWalletBrowser(htmlOverride);
2321
#elif UNITY_WEBGL
24-
_unityBrowser = go.AddComponent<WebGLInAppWalletBrowser>();
22+
#if UNITY_6000_0_OR_NEWER
23+
var existingBrowser = UnityEngine.Object.FindAnyObjectByType<WebGLInAppWalletBrowser>();
24+
#else
25+
var existingBrowser = GameObject.FindObjectOfType<WebGLInAppWalletBrowser>();
26+
#endif
27+
if (existingBrowser != null)
28+
{
29+
_unityBrowser = existingBrowser;
30+
}
31+
else
32+
{
33+
var go = new GameObject("WebGLInAppWalletBrowser");
34+
_unityBrowser = go.AddComponent<WebGLInAppWalletBrowser>();
35+
}
2536
#elif UNITY_ANDROID
2637
_unityBrowser = new AndroidBrowser();
2738
#elif UNITY_IOS

0 commit comments

Comments
 (0)