4
4
using System . Runtime . InteropServices ;
5
5
using System . Threading . Tasks ;
6
6
using Newtonsoft . Json ;
7
+ using UnityEngine ;
7
8
8
9
namespace Thirdweb
9
10
{
@@ -45,10 +46,18 @@ private static void jsCallback(string taskId, string result, string error)
45
46
}
46
47
47
48
public static void Initialize ( string chainOrRPC , ThirdwebSDK . Options options ) {
49
+ if ( Application . isEditor ) {
50
+ Debug . LogWarning ( "Initializing the thirdweb SDK is not supported in the editor. Please build and run the app instead." ) ;
51
+ return ;
52
+ }
48
53
ThirdwebInitialize ( chainOrRPC , Utils . ToJson ( options ) ) ;
49
54
}
50
55
51
56
public static async Task < string > Connect ( ) {
57
+ if ( Application . isEditor ) {
58
+ Debug . LogWarning ( "Connecting wallets is not supported in the editor. Please build and run the app instead." ) ;
59
+ return "0x0000000000000000000000000000000000000000" ;
60
+ }
52
61
var task = new TaskCompletionSource < string > ( ) ;
53
62
string taskId = Guid . NewGuid ( ) . ToString ( ) ;
54
63
taskMap [ taskId ] = task ;
@@ -58,11 +67,19 @@ public static async Task<string> Connect() {
58
67
}
59
68
60
69
public static void SwitchNetwork ( int chainId ) {
70
+ if ( Application . isEditor ) {
71
+ Debug . LogWarning ( "Switching networks is not supported in the editor. Please build and run the app instead." ) ;
72
+ return ;
73
+ }
61
74
ThirdwebSwitchNetwork ( chainId ) ;
62
75
}
63
76
64
77
public static async Task < T > InvokeRoute < T > ( string route , string [ ] body )
65
78
{
79
+ if ( Application . isEditor ) {
80
+ Debug . LogWarning ( "Interacting with the thirdweb SDK is not supported in the editor. Please build and run the app instead." ) ;
81
+ return default ( T ) ;
82
+ }
66
83
var msg = Utils . ToJson ( new RequestMessageBody ( body ) ) ;
67
84
string taskId = Guid . NewGuid ( ) . ToString ( ) ;
68
85
var task = new TaskCompletionSource < string > ( ) ;
0 commit comments