File tree 1 file changed +14
-3
lines changed
Assets/Thirdweb/Runtime/Unity/Browser
1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -16,12 +16,23 @@ public CrossPlatformUnityBrowser(string htmlOverride = null)
16
16
htmlOverride = null ;
17
17
}
18
18
19
- var go = new GameObject ( "WebGLInAppWalletBrowser" ) ;
20
-
21
19
#if UNITY_EDITOR
22
20
_unityBrowser = new InAppWalletBrowser ( htmlOverride ) ;
23
21
#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
+ }
25
36
#elif UNITY_ANDROID
26
37
_unityBrowser = new AndroidBrowser ( ) ;
27
38
#elif UNITY_IOS
You can’t perform that action at this time.
0 commit comments