Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: thirdweb-dev/unity
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v5.13.1
Choose a base ref
...
head repository: thirdweb-dev/unity
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v5
Choose a head ref

Commits on Jan 6, 2025

  1. .NET 2.13.0 // Burn Extensions & RPC Overrides

    0xFirekeeper committed Jan 6, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    0xFirekeeper Firekeeper
    Copy the full SHA
    082b7ec View commit details
  2. Expose RPC Overrides in ThirdwebManager

    0xFirekeeper committed Jan 6, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    0xFirekeeper Firekeeper
    Copy the full SHA
    a0ac7bd View commit details
  3. Expose WC Included Wallet IDs in ThirdwebManager

    Also add tooltips
    0xFirekeeper committed Jan 6, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    0xFirekeeper Firekeeper
    Copy the full SHA
    f5f85ac View commit details
  4. ver

    0xFirekeeper committed Jan 6, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    0xFirekeeper Firekeeper
    Copy the full SHA
    c728323 View commit details

Commits on Jan 7, 2025

  1. Autoconnect Feature (#224)

    0xFirekeeper authored Jan 7, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    28e6508 View commit details
  2. ver

    0xFirekeeper committed Jan 7, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    0xFirekeeper Firekeeper
    Copy the full SHA
    e0330ba View commit details

Commits on Jan 10, 2025

  1. .NET 2.15.0 // Backend IAW + System time edge case

    0xFirekeeper committed Jan 10, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    0xFirekeeper Firekeeper
    Copy the full SHA
    40df1f3 View commit details
  2. Backend Auth + ThirdwebManagerServer (#225)

    0xFirekeeper authored Jan 10, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    ded83a7 View commit details
  3. ver

    0xFirekeeper committed Jan 10, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    0xFirekeeper Firekeeper
    Copy the full SHA
    ba74311 View commit details
  4. fix: walletSecret not passed down correctly

    repackaging 5.15.0 with patch
    0xFirekeeper committed Jan 10, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    0xFirekeeper Firekeeper
    Copy the full SHA
    e03948f View commit details

Commits on Jan 15, 2025

  1. Update README.md

    Signed-off-by: Firekeeper <0xFirekeeper@gmail.com>
    0xFirekeeper authored Jan 15, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    7aa8665 View commit details
  2. fix 2021 compile error

    0xFirekeeper committed Jan 15, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    0xFirekeeper Firekeeper
    Copy the full SHA
    368e5a7 View commit details
  3. Verified

    This commit was signed with the committer’s verified signature.
    0xFirekeeper Firekeeper
    Copy the full SHA
    056f436 View commit details
  4. Merge branch 'v5' of https://github.com/thirdweb-dev/unity into v5

    0xFirekeeper committed Jan 15, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    0xFirekeeper Firekeeper
    Copy the full SHA
    f1179d8 View commit details
  5. ver

    0xFirekeeper committed Jan 15, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    0xFirekeeper Firekeeper
    Copy the full SHA
    a4da750 View commit details

Commits on Jan 17, 2025

  1. fix edge case app identifier = "" or whitespace

    0xFirekeeper committed Jan 17, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    0xFirekeeper Firekeeper
    Copy the full SHA
    e620559 View commit details
  2. .NET 2.16.0 // SiweExternal Auth & Guest SessionID

    0xFirekeeper committed Jan 17, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    0xFirekeeper Firekeeper
    Copy the full SHA
    0f10ab3 View commit details
  3. pass siwe ids in iaw/eco opts

    0xFirekeeper committed Jan 17, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    0xFirekeeper Firekeeper
    Copy the full SHA
    1d5b969 View commit details
  4. ver

    0xFirekeeper committed Jan 17, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    0xFirekeeper Firekeeper
    Copy the full SHA
    554a14d View commit details

Commits on Jan 24, 2025

  1. .NET 2.17.0 // Nebula Beta & Enhanced Analytics

    0xFirekeeper committed Jan 24, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    0xFirekeeper Firekeeper
    Copy the full SHA
    9f21e1c View commit details
  2. Improve MetaMask Disconnection

    0xFirekeeper committed Jan 24, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    0xFirekeeper Firekeeper
    Copy the full SHA
    8701289 View commit details
  3. Update README.md

    Signed-off-by: Firekeeper <0xFirekeeper@gmail.com>
    0xFirekeeper authored Jan 24, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    5a55d4e View commit details
  4. Update README.md

    Signed-off-by: Firekeeper <0xFirekeeper@gmail.com>
    0xFirekeeper authored Jan 24, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    2bc32ad View commit details
  5. ver

    0xFirekeeper committed Jan 24, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    0xFirekeeper Firekeeper
    Copy the full SHA
    c9b81e3 View commit details

Commits on Feb 7, 2025

  1. .NET 2.17.1 // NFT.QuantityOwned Fix

    0xFirekeeper committed Feb 7, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    0xFirekeeper Firekeeper
    Copy the full SHA
    3758028 View commit details
  2. ver

    0xFirekeeper committed Feb 7, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    0xFirekeeper Firekeeper
    Copy the full SHA
    b7ae06e View commit details

Commits on Feb 13, 2025

  1. .NET 2.17.2 // Token Login, Timeouts, SK Rotation

    0xFirekeeper committed Feb 13, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    0xFirekeeper Firekeeper
    Copy the full SHA
    c23633e View commit details
  2. ver

    0xFirekeeper committed Feb 13, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    0xFirekeeper Firekeeper
    Copy the full SHA
    994c22b View commit details

Commits on Feb 21, 2025

  1. .NET 2.18.0 // Insight & EngineWallet

    0xFirekeeper committed Feb 21, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    0xFirekeeper Firekeeper
    Copy the full SHA
    45fbb1d View commit details
  2. ver

    0xFirekeeper committed Feb 21, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    0xFirekeeper Firekeeper
    Copy the full SHA
    9a1a87d View commit details
  3. .NET 2.18.1 // ThirdwebInsight.GetTransactions

    0xFirekeeper committed Feb 21, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    0xFirekeeper Firekeeper
    Copy the full SHA
    f62729d View commit details
  4. ver

    0xFirekeeper committed Feb 21, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    0xFirekeeper Firekeeper
    Copy the full SHA
    cfc0941 View commit details

Commits on Feb 28, 2025

  1. .NET 2.18.2 // Insight NFT Metadata

    0xFirekeeper committed Feb 28, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    0xFirekeeper Firekeeper
    Copy the full SHA
    c8fb417 View commit details
  2. ver

    0xFirekeeper committed Feb 28, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    0xFirekeeper Firekeeper
    Copy the full SHA
    c29b84b View commit details

Commits on Mar 11, 2025

  1. Fix WebGL Duplicate Popup State

    0xFirekeeper committed Mar 11, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    0xFirekeeper Firekeeper
    Copy the full SHA
    f88f81f View commit details
  2. ver

    0xFirekeeper committed Mar 11, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    0xFirekeeper Firekeeper
    Copy the full SHA
    94812c8 View commit details

Commits on Mar 12, 2025

  1. Verified

    This commit was signed with the committer’s verified signature.
    0xFirekeeper Firekeeper
    Copy the full SHA
    a118cc5 View commit details
  2. ver

    0xFirekeeper committed Mar 12, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    0xFirekeeper Firekeeper
    Copy the full SHA
    24fdc20 View commit details
  3. Verified

    This commit was signed with the committer’s verified signature.
    0xFirekeeper Firekeeper
    Copy the full SHA
    d0fc0c4 View commit details
  4. ver

    0xFirekeeper committed Mar 12, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    0xFirekeeper Firekeeper
    Copy the full SHA
    c312d65 View commit details

Commits on Mar 13, 2025

  1. Verified

    This commit was signed with the committer’s verified signature.
    0xFirekeeper Firekeeper
    Copy the full SHA
    312475a View commit details
  2. ver

    0xFirekeeper committed Mar 13, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    0xFirekeeper Firekeeper
    Copy the full SHA
    ce2a2f9 View commit details
  3. cleanup test

    0xFirekeeper committed Mar 13, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    0xFirekeeper Firekeeper
    Copy the full SHA
    6ab283e View commit details
  4. Future-proof dynCalls (#233)

    0xFirekeeper authored Mar 13, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    a4ebd59 View commit details
  5. ver

    0xFirekeeper committed Mar 13, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    0xFirekeeper Firekeeper
    Copy the full SHA
    2c7cb36 View commit details

Commits on Mar 19, 2025

  1. Verified

    This commit was signed with the committer’s verified signature.
    0xFirekeeper Firekeeper
    Copy the full SHA
    552402e View commit details
  2. ver

    0xFirekeeper committed Mar 19, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    0xFirekeeper Firekeeper
    Copy the full SHA
    cfe3d5b View commit details

Commits on Mar 21, 2025

  1. .NET 2.19.0 // [Beta] Universal Bridge

    0xFirekeeper committed Mar 21, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    0xFirekeeper Firekeeper
    Copy the full SHA
    7d2c3a3 View commit details

Commits on Mar 22, 2025

  1. ver

    0xFirekeeper committed Mar 22, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    0xFirekeeper Firekeeper
    Copy the full SHA
    b372d0a View commit details

Commits on Mar 26, 2025

  1. Support for other injected wallets when using MetaMaskWallet

    Tested with Rabby + WalletProvider.MetaMaskWallet
    0xFirekeeper committed Mar 26, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    0xFirekeeper Firekeeper
    Copy the full SHA
    a2e8c8f View commit details
Showing with 1,172 additions and 736 deletions.
  1. +151 −119 Assets/Thirdweb/Editor/ThirdwebManagerEditor.cs
  2. +1 −0 Assets/Thirdweb/Examples/Scripts/PlaygroundManager.cs
  3. +4 −0 Assets/Thirdweb/Plugins/ThreadingPatcher/Editor/WebGLThreadingPatcher.cs
  4. +1 −1 Assets/Thirdweb/Plugins/ThreadingPatcher/Plugins/SystemThreadingTimer.jslib
  5. +5 −5 ...lugins/WalletConnectUnity/com.walletconnect.core/Runtime/External/NativeWebSocket/WebSocket.jslib
  6. +2 −2 Assets/Thirdweb/Plugins/WebGLInputCopy/WebGLInput/Mobile/WebGLInputMobile.jslib
  7. +6 −19 Assets/Thirdweb/Plugins/WebGLInputCopy/WebGLInput/WebGLInput.jslib
  8. +7 −16 Assets/Thirdweb/Plugins/WebGLInputCopy/WebGLWindow/WebGLWindow.jslib
  9. BIN Assets/Thirdweb/Runtime/NET/Thirdweb.dll
  10. +14 −3 Assets/Thirdweb/Runtime/Unity/Browser/CrossPlatformUnityBrowser.cs
  11. +2 −0 Assets/Thirdweb/Runtime/Unity/Prefabs/ThirdwebManager.prefab
  12. +55 −0 Assets/Thirdweb/Runtime/Unity/Prefabs/ThirdwebManagerServer.prefab
  13. +7 −0 Assets/Thirdweb/Runtime/Unity/Prefabs/ThirdwebManagerServer.prefab.meta
  14. +16 −482 Assets/Thirdweb/Runtime/Unity/ThirdwebManager.cs
  15. +639 −0 Assets/Thirdweb/Runtime/Unity/ThirdwebManagerBase.cs
  16. +11 −0 Assets/Thirdweb/Runtime/Unity/ThirdwebManagerBase.cs.meta
  17. +40 −0 Assets/Thirdweb/Runtime/Unity/ThirdwebManagerServer.cs
  18. +11 −0 Assets/Thirdweb/Runtime/Unity/ThirdwebManagerServer.cs.meta
  19. +32 −1 Assets/Thirdweb/Runtime/Unity/ThirdwebUnityExtensions.cs
  20. +44 −20 Assets/Thirdweb/Runtime/Unity/Wallets/Core/MetaMaskWallet.cs
  21. +9 −4 Assets/Thirdweb/Runtime/Unity/Wallets/Core/WalletConnectWallet.cs
  22. +2 −1 Assets/Thirdweb/Runtime/Unity/Wallets/Core/WebGLMetaMask.cs
  23. +31 −0 Assets/Thirdweb/Runtime/Unity/WebGL/WebGLCopyBuffer.jslib
  24. +32 −0 Assets/Thirdweb/Runtime/Unity/WebGL/WebGLCopyBuffer.jslib.meta
  25. +1 −1 ProjectSettings/ProjectSettings.asset
  26. +49 −62 README.md
270 changes: 151 additions & 119 deletions Assets/Thirdweb/Editor/ThirdwebManagerEditor.cs
Original file line number Diff line number Diff line change
@@ -5,119 +5,59 @@

namespace Thirdweb.Editor
{
[CustomEditor(typeof(ThirdwebManager))]
public class ThirdwebManagerEditor : UnityEditor.Editor
public abstract class ThirdwebManagerBaseEditor<T> : UnityEditor.Editor
where T : MonoBehaviour
{
private SerializedProperty clientIdProp;
private SerializedProperty bundleIdProp;
private SerializedProperty initializeOnAwakeProp;
private SerializedProperty showDebugLogsProp;
private SerializedProperty optOutUsageAnalyticsProp;
private SerializedProperty supportedChainsProp;
private SerializedProperty redirectPageHtmlOverrideProp;

private int selectedTab = 0;
private readonly string[] tabTitles = { "Client", "Preferences", "Misc", "Debug" };
protected SerializedProperty initializeOnAwakeProp;
protected SerializedProperty showDebugLogsProp;
protected SerializedProperty autoConnectLastWalletProp;
protected SerializedProperty supportedChainsProp;
protected SerializedProperty includedWalletIdsProp;
protected SerializedProperty redirectPageHtmlOverrideProp;
protected SerializedProperty rpcOverridesProp;

private GUIStyle headerStyle;
private GUIStyle buttonStyle;
protected int selectedTab;
protected GUIStyle buttonStyle;
protected Texture2D bannerImage;

private Texture2D bannerImage;
protected virtual string[] TabTitles => new string[] { "Client/Server", "Preferences", "Misc", "Debug" };

private void OnEnable()
protected virtual void OnEnable()
{
clientIdProp = FindProperty("ClientId");
bundleIdProp = FindProperty("BundleId");
initializeOnAwakeProp = FindProperty("InitializeOnAwake");
showDebugLogsProp = FindProperty("ShowDebugLogs");
optOutUsageAnalyticsProp = FindProperty("OptOutUsageAnalytics");
supportedChainsProp = FindProperty("SupportedChains");
redirectPageHtmlOverrideProp = FindProperty("RedirectPageHtmlOverride");
initializeOnAwakeProp = FindProp("InitializeOnAwake");
showDebugLogsProp = FindProp("ShowDebugLogs");
autoConnectLastWalletProp = FindProp("AutoConnectLastWallet");
supportedChainsProp = FindProp("SupportedChains");
includedWalletIdsProp = FindProp("IncludedWalletIds");
redirectPageHtmlOverrideProp = FindProp("RedirectPageHtmlOverride");
rpcOverridesProp = FindProp("RpcOverrides");

bannerImage = Resources.Load<Texture2D>("EditorBanner");
}

private void InitializeStyles()
{
buttonStyle = new GUIStyle(GUI.skin.button)
{
fontStyle = FontStyle.Bold,
alignment = TextAnchor.MiddleLeft,
padding = new RectOffset(10, 10, 10, 10)
};
}

private SerializedProperty FindProperty(string propertyName)
{
var targetType = target.GetType();
var property = targetType.GetProperty(propertyName, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
if (property == null)
return null;

var backingFieldName = $"<{propertyName}>k__BackingField";
return serializedObject.FindProperty(backingFieldName);
}

public override void OnInspectorGUI()
{
serializedObject.Update();

if (headerStyle == null || buttonStyle == null)
if (buttonStyle == null)
{
InitializeStyles();
}

// Draw Banner and Title
DrawBannerAndTitle();

// Draw Tab Bar
DrawTabs();

// Draw Selected Tab Content
GUILayout.Space(10);
DrawSelectedTabContent();

serializedObject.ApplyModifiedProperties();
}

private void DrawBannerAndTitle()
{
GUILayout.BeginVertical();
GUILayout.Space(10);

GUILayout.BeginHorizontal();

if (bannerImage != null)
{
GUILayout.Label(bannerImage, GUILayout.Width(64), GUILayout.Height(64));
}

GUILayout.Space(10);

GUILayout.BeginVertical();
GUILayout.Space(10);
GUILayout.Label("Thirdweb Configuration", EditorStyles.boldLabel);
GUILayout.Label("Configure your settings and preferences.\nYou can access ThirdwebManager.Instance from anywhere.", EditorStyles.miniLabel);
GUILayout.EndVertical();

GUILayout.EndHorizontal();

GUILayout.Space(10);

GUILayout.EndVertical();
}

private void DrawTabs()
{
selectedTab = GUILayout.Toolbar(selectedTab, tabTitles, GUILayout.Height(25));
}

private void DrawSelectedTabContent()
protected virtual void DrawSelectedTabContent()
{
switch (selectedTab)
{
case 0:
DrawClientTab();
DrawClientOrServerTab();
break;
case 1:
DrawPreferencesTab();
@@ -134,62 +74,54 @@ private void DrawSelectedTabContent()
}
}

private void DrawClientTab()
{
EditorGUILayout.HelpBox("Configure your client settings here.", MessageType.Info);
DrawProperty(clientIdProp, "Client ID");
DrawProperty(bundleIdProp, "Bundle ID");
DrawButton(
"Create API Key",
() =>
{
Application.OpenURL("https://thirdweb.com/create-api-key");
}
);
}
protected abstract void DrawClientOrServerTab();

private void DrawPreferencesTab()
protected virtual void DrawPreferencesTab()
{
EditorGUILayout.HelpBox("Set your preferences and initialization options here.", MessageType.Info);
DrawProperty(initializeOnAwakeProp, "Initialize On Awake");
DrawProperty(showDebugLogsProp, "Show Debug Logs");
DrawProperty(optOutUsageAnalyticsProp, "Opt-Out of Usage Analytics");
DrawProperty(autoConnectLastWalletProp, "Auto-Connect Last Wallet");
}

private void DrawMiscTab()
protected virtual void DrawMiscTab()
{
EditorGUILayout.HelpBox("Configure other settings here.", MessageType.Info);

// Wallet Connect Settings
GUILayout.Label("Wallet Connect Settings", EditorStyles.boldLabel);
DrawProperty(supportedChainsProp, "Supported Chains");

DrawProperty(rpcOverridesProp, "RPC Overrides");
GUILayout.Space(10);

// Desktop OAuth Settings
GUILayout.Label("Desktop OAuth Settings", EditorStyles.boldLabel);
EditorGUILayout.LabelField("Redirect Page HTML Override", EditorStyles.boldLabel);
EditorGUILayout.LabelField("OAuth Redirect Page HTML Override", EditorStyles.boldLabel);
redirectPageHtmlOverrideProp.stringValue = EditorGUILayout.TextArea(redirectPageHtmlOverrideProp.stringValue, GUILayout.MinHeight(75));
GUILayout.Space(10);
DrawProperty(supportedChainsProp, "WalletConnect Supported Chains");
DrawProperty(includedWalletIdsProp, "WalletConnect Included Wallet IDs");
}

private void DrawDebugTab()
protected virtual void DrawDebugTab()
{
EditorGUILayout.HelpBox("Debug your settings here.", MessageType.Info);

DrawButton(
"Log Active Wallet Info",
() =>
{
if (Application.isPlaying)
{
var wallet = ((ThirdwebManager)target).GetActiveWallet();
if (wallet != null)
var mgr = target as T;
var method = mgr.GetType().GetMethod("GetActiveWallet", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (method != null)
{
Debug.Log($"Active Wallet ({wallet.GetType().Name}) Address: {wallet.GetAddress().Result}");
var wallet = method.Invoke(mgr, null) as IThirdwebWallet;
if (wallet != null)
{
Debug.Log($"Active Wallet ({wallet.GetType().Name}) Address: {wallet.GetAddress().Result}");
}
else
{
Debug.LogWarning("No active wallet found.");
}
}
else
{
Debug.LogWarning("No active wallet found.");
Debug.LogWarning("GetActiveWallet() not found.");
}
}
else
@@ -198,7 +130,6 @@ private void DrawDebugTab()
}
}
);

DrawButton(
"Open Documentation",
() =>
@@ -208,7 +139,42 @@ private void DrawDebugTab()
);
}

private void DrawProperty(SerializedProperty property, string label)
protected void DrawBannerAndTitle()
{
GUILayout.BeginVertical();
GUILayout.Space(10);
GUILayout.BeginHorizontal();
if (bannerImage != null)
{
GUILayout.Label(bannerImage, GUILayout.Width(64), GUILayout.Height(64));
}
GUILayout.Space(10);
GUILayout.BeginVertical();
GUILayout.Space(10);
GUILayout.Label("Thirdweb Configuration", EditorStyles.boldLabel);
GUILayout.Label("Configure your settings and preferences.\nYou can access ThirdwebManager.Instance from anywhere.", EditorStyles.miniLabel);
GUILayout.EndVertical();
GUILayout.EndHorizontal();
GUILayout.Space(10);
GUILayout.EndVertical();
}

protected void DrawTabs()
{
selectedTab = GUILayout.Toolbar(selectedTab, TabTitles, GUILayout.Height(25));
}

protected void InitializeStyles()
{
buttonStyle = new GUIStyle(GUI.skin.button)
{
fontStyle = FontStyle.Bold,
alignment = TextAnchor.MiddleLeft,
padding = new RectOffset(10, 10, 10, 10)
};
}

protected void DrawProperty(SerializedProperty property, string label)
{
if (property != null)
{
@@ -220,15 +186,81 @@ private void DrawProperty(SerializedProperty property, string label)
}
}

private void DrawButton(string label, System.Action action)
protected void DrawButton(string label, System.Action action)
{
GUILayout.FlexibleSpace();
// center label
if (GUILayout.Button(label, buttonStyle, GUILayout.Height(35), GUILayout.ExpandWidth(true)))
{
action.Invoke();
}
GUILayout.FlexibleSpace();
}

protected SerializedProperty FindProp(string propName)
{
var targetType = target.GetType();
var property = targetType.GetProperty(propName, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
if (property == null)
return null;
var backingFieldName = $"<{propName}>k__BackingField";
return serializedObject.FindProperty(backingFieldName);
}
}

[CustomEditor(typeof(ThirdwebManager))]
public class ThirdwebManagerEditor : ThirdwebManagerBaseEditor<ThirdwebManager>
{
SerializedProperty clientIdProp;
SerializedProperty bundleIdProp;

protected override void OnEnable()
{
base.OnEnable();
clientIdProp = FindProp("ClientId");
bundleIdProp = FindProp("BundleId");
}

protected override string[] TabTitles => new string[] { "Client", "Preferences", "Misc", "Debug" };

protected override void DrawClientOrServerTab()
{
EditorGUILayout.HelpBox("Configure your client settings here.", MessageType.Info);
DrawProperty(clientIdProp, "Client ID");
DrawProperty(bundleIdProp, "Bundle ID");
DrawButton(
"Create API Key",
() =>
{
Application.OpenURL("https://thirdweb.com/create-api-key");
}
);
}
}

[CustomEditor(typeof(ThirdwebManagerServer))]
public class ThirdwebManagerServerEditor : ThirdwebManagerBaseEditor<ThirdwebManagerServer>
{
SerializedProperty secretKeyProp;

protected override void OnEnable()
{
base.OnEnable();
secretKeyProp = FindProp("SecretKey");
}

protected override string[] TabTitles => new string[] { "Client", "Preferences", "Misc", "Debug" };

protected override void DrawClientOrServerTab()
{
EditorGUILayout.HelpBox("Configure your client settings here.", MessageType.Info);
DrawProperty(secretKeyProp, "Secret Key");
DrawButton(
"Create API Key",
() =>
{
Application.OpenURL("https://thirdweb.com/create-api-key");
}
);
}
}
}
1 change: 1 addition & 0 deletions Assets/Thirdweb/Examples/Scripts/PlaygroundManager.cs
Original file line number Diff line number Diff line change
@@ -125,6 +125,7 @@ private async void ConnectWallet(WalletOptions options)
currentPanel.Action1Button.onClick.AddListener(async () =>
{
var address = await wallet.GetAddress();
address.CopyToClipboard();
Log(currentPanel.LogText, $"Address: {address}");
});

Original file line number Diff line number Diff line change
@@ -18,7 +18,11 @@ public void OnPostBuildPlayerScriptDLLs(BuildReport report)
if (report.summary.platform != BuildTarget.WebGL)
return;

#if UNITY_2022_1_OR_NEWER
var mscorLibDll = report.GetFiles().FirstOrDefault(f => f.path.EndsWith("mscorlib.dll")).path;
#else
var mscorLibDll = report.files.FirstOrDefault(f => f.path.EndsWith("mscorlib.dll")).path;
#endif
if (mscorLibDll == null)
{
Debug.LogError("Can't find mscorlib.dll in build dll files");
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ var SystemThreadingTimerLib = {
setTimeout(function()
{
if (id === vars.currentCallbackId)
Runtime.dynCall('v', vars.callback);
{{{ makeDynCall("v", "vars.callback") }}}();
},
interval);
}
Original file line number Diff line number Diff line change
@@ -150,7 +150,7 @@ var LibraryWebSocket = {
console.log("[JSLIB WebSocket] Connected.");

if (webSocketState.onOpen)
Module.dynCall_vi(webSocketState.onOpen, instanceId);
{{{ makeDynCall("vi", "webSocketState.onOpen") }}}(instanceId);

};

@@ -170,7 +170,7 @@ var LibraryWebSocket = {
HEAPU8.set(dataBuffer, buffer);

try {
Module.dynCall_viii(webSocketState.onMessage, instanceId, buffer, dataBuffer.length);
{{{ makeDynCall("viii", "webSocketState.onMessage") }}}(instanceId, buffer, dataBuffer.length);
} finally {
_free(buffer);
}
@@ -182,7 +182,7 @@ var LibraryWebSocket = {
HEAPU8.set(dataBuffer, buffer);

try {
Module.dynCall_viii(webSocketState.onMessage, instanceId, buffer, dataBuffer.length);
{{{ makeDynCall("viii", "webSocketState.onMessage") }}}(instanceId, buffer, dataBuffer.length);
} finally {
_free(buffer);
}
@@ -204,7 +204,7 @@ var LibraryWebSocket = {
stringToUTF8(msg, buffer, length);

try {
Module.dynCall_vii(webSocketState.onError, instanceId, buffer);
{{{ makeDynCall("vii", "webSocketState.onError") }}}(instanceId, buffer);
} finally {
_free(buffer);
}
@@ -219,7 +219,7 @@ var LibraryWebSocket = {
console.log("[JSLIB WebSocket] Closed.");

if (webSocketState.onClose)
Module.dynCall_vii(webSocketState.onClose, instanceId, ev.code);
{{{ makeDynCall("vii", "webSocketState.onClose") }}}(instanceId, ev.code);

delete instance.ws;

Original file line number Diff line number Diff line change
@@ -6,15 +6,15 @@ var WebGLInputMobile = {

document.body.addEventListener("touchend", function () {
document.body.removeEventListener("touchend", arguments.callee);
Runtime.dynCall("vi", touchend, [id]);
{{{ makeDynCall("vi", "touchend") }}}(id);
});

return id;
},
WebGLInputMobileOnFocusOut: function (id, focusout) {
document.body.addEventListener("focusout", function () {
document.body.removeEventListener("focusout", arguments.callee);
Runtime.dynCall("vi", focusout, [id]);
{{{ makeDynCall("vi", "focusout") }}}(id);
});
},
}
25 changes: 6 additions & 19 deletions Assets/Thirdweb/Plugins/WebGLInputCopy/WebGLInput/WebGLInput.jslib
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
var WebGLInput = {
$instances: [],
WebGLInputInit : function() {
// use WebAssembly.Table : makeDynCall
// when enable. dynCall is undefined
if(typeof dynCall === "undefined")
{
// make Runtime.dynCall to undefined
Runtime = { dynCall : undefined }
}
else
{
// Remove the `Runtime` object from "v1.37.27: 12/24/2017"
// if Runtime not defined. create and add functon!!
if(typeof Runtime === "undefined") Runtime = { dynCall : dynCall }
}
},
WebGLInputCreate: function (canvasId, x, y, width, height, fontsize, text, placeholder, isMultiLine, isPassword, isHidden, isMobile) {

@@ -112,7 +99,7 @@ var WebGLInput = {
input.setSelectionRange(start + 1, start + 1);
input.oninput(); // call oninput to exe ValueChange function!!
} else {
(!!Runtime.dynCall) ? Runtime.dynCall("vii", cb, [id, e.shiftKey ? -1 : 1]) : {{{ makeDynCall("vii", "cb") }}}(id, e.shiftKey ? -1 : 1);
{{{ makeDynCall("vii", "cb") }}}(id, e.shiftKey ? -1 : 1);
}
}
});
@@ -124,13 +111,13 @@ var WebGLInput = {
WebGLInputOnFocus: function (id, cb) {
var input = instances[id];
input.onfocus = function () {
(!!Runtime.dynCall) ? Runtime.dynCall("vi", cb, [id]) : {{{ makeDynCall("vi", "cb") }}}(id);
{{{ makeDynCall("vi", "cb") }}}(id);
};
},
WebGLInputOnBlur: function (id, cb) {
var input = instances[id];
input.onblur = function () {
(!!Runtime.dynCall) ? Runtime.dynCall("vi", cb, [id]) : {{{ makeDynCall("vi", "cb") }}}(id);
{{{ makeDynCall("vi", "cb") }}}(id);
};
},
WebGLInputIsFocus: function (id) {
@@ -143,7 +130,7 @@ var WebGLInput = {
var bufferSize = lengthBytesUTF8(returnStr) + 1;
var buffer = _malloc(bufferSize);
stringToUTF8(returnStr, buffer, bufferSize);
(!!Runtime.dynCall) ? Runtime.dynCall("vii", cb, [id, buffer]) : {{{ makeDynCall("vii", "cb") }}}(id, buffer);
{{{ makeDynCall("vii", "cb") }}}(id, buffer);
};
},
WebGLInputOnEditEnd:function(id, cb){
@@ -153,7 +140,7 @@ var WebGLInput = {
var bufferSize = lengthBytesUTF8(returnStr) + 1;
var buffer = _malloc(bufferSize);
stringToUTF8(returnStr, buffer, bufferSize);
(!!Runtime.dynCall) ? Runtime.dynCall("vii", cb, [id, buffer]) : {{{ makeDynCall("vii", "cb") }}}(id, buffer);
{{{ makeDynCall("vii", "cb") }}}(id, buffer);
};
},
WebGLInputOnKeyboardEvent:function(id, cb){
@@ -167,7 +154,7 @@ var WebGLInput = {
var shift = e.shiftKey ? 1 : 0;
var ctrl = e.ctrlKey ? 1 : 0;
var alt = e.altKey ? 1 : 0;
(!!Runtime.dynCall) ? Runtime.dynCall("viiiiiii", cb, [id, mode, key, code, shift, ctrl, alt]) : {{{ makeDynCall("viiiiiii", "cb") }}}(id, mode, key, code, shift, ctrl, alt);
{{{ makeDynCall("viiiiiii", "cb") }}}(id, mode, key, code, shift, ctrl, alt);
}
}
input.addEventListener('keydown', function(e) { func(1, e); });
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
#if parseInt(EMSCRIPTEN_VERSION.split('.')[0]) < 2 || (parseInt(EMSCRIPTEN_VERSION.split('.')[0]) == 2 && parseInt(EMSCRIPTEN_VERSION.split('.')[1]) < 0) || (parseInt(EMSCRIPTEN_VERSION.split('.')[0]) == 2 && parseInt(EMSCRIPTEN_VERSION.split('.')[1]) == 0 && parseInt(EMSCRIPTEN_VERSION.split('.')[2]) < 3)
#error "ThirdWeb plugin requires building with Emscripten 2.0.3 and Unity 2021.2 or newer. Please update"
#endif

var WebGLWindow = {
WebGLWindowInit : function() {
// use WebAssembly.Table : makeDynCall
// when enable. dynCall is undefined
if(typeof dynCall === "undefined")
{
// make Runtime.dynCall to undefined
Runtime = { dynCall : undefined }
}
else
{
// Remove the `Runtime` object from "v1.37.27: 12/24/2017"
// if Runtime not defined. create and add functon!!
if(typeof Runtime === "undefined") Runtime = { dynCall : dynCall }
}
},
WebGLWindowGetCanvasName: function() {
var elements = document.getElementsByTagName('canvas');
@@ -33,17 +24,17 @@ var WebGLWindow = {
},
WebGLWindowOnFocus: function (cb) {
window.addEventListener('focus', function () {
(!!Runtime.dynCall) ? Runtime.dynCall("v", cb, []) : {{{ makeDynCall("v", "cb") }}}();
{{{ makeDynCall("v", "cb") }}}();
});
},
WebGLWindowOnBlur: function (cb) {
window.addEventListener('blur', function () {
(!!Runtime.dynCall) ? Runtime.dynCall("v", cb, []) : {{{ makeDynCall("v", "cb") }}}();
{{{ makeDynCall("v", "cb") }}}();
});
},
WebGLWindowOnResize: function(cb) {
window.addEventListener('resize', function () {
(!!Runtime.dynCall) ? Runtime.dynCall("v", cb, []) : {{{ makeDynCall("v", "cb") }}}();
{{{ makeDynCall("v", "cb") }}}();
});
},
WebGLWindowInjectFullscreen : function () {
Binary file modified Assets/Thirdweb/Runtime/NET/Thirdweb.dll
Binary file not shown.
17 changes: 14 additions & 3 deletions Assets/Thirdweb/Runtime/Unity/Browser/CrossPlatformUnityBrowser.cs
Original file line number Diff line number Diff line change
@@ -16,12 +16,23 @@ public CrossPlatformUnityBrowser(string htmlOverride = null)
htmlOverride = null;
}

var go = new GameObject("WebGLInAppWalletBrowser");

#if UNITY_EDITOR
_unityBrowser = new InAppWalletBrowser(htmlOverride);
#elif UNITY_WEBGL
_unityBrowser = go.AddComponent<WebGLInAppWalletBrowser>();
#if UNITY_6000_0_OR_NEWER
var existingBrowser = UnityEngine.Object.FindAnyObjectByType<WebGLInAppWalletBrowser>();
#else
var existingBrowser = GameObject.FindObjectOfType<WebGLInAppWalletBrowser>();
#endif
if (existingBrowser != null)
{
_unityBrowser = existingBrowser;
}
else
{
var go = new GameObject("WebGLInAppWalletBrowser");
_unityBrowser = go.AddComponent<WebGLInAppWalletBrowser>();
}
#elif UNITY_ANDROID
_unityBrowser = new AndroidBrowser();
#elif UNITY_IOS
2 changes: 2 additions & 0 deletions Assets/Thirdweb/Runtime/Unity/Prefabs/ThirdwebManager.prefab
Original file line number Diff line number Diff line change
@@ -52,7 +52,9 @@ MonoBehaviour:
<ShowDebugLogs>k__BackingField: 1
<OptOutUsageAnalytics>k__BackingField: 0
<SupportedChains>k__BackingField: ee6e060000000000
<IncludedWalletIds>k__BackingField: []
<RedirectPageHtmlOverride>k__BackingField:
<RpcOverrides>k__BackingField: []
--- !u!1001 &5352000285921552497
PrefabInstance:
m_ObjectHideFlags: 0
55 changes: 55 additions & 0 deletions Assets/Thirdweb/Runtime/Unity/Prefabs/ThirdwebManagerServer.prefab
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &2985666425045432145
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7977017408921700919}
- component: {fileID: 5964706357837968276}
m_Layer: 0
m_Name: ThirdwebManagerServer
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &7977017408921700919
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2985666425045432145}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &5964706357837968276
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2985666425045432145}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a197f9da6b1311840bb25b207982e287, type: 3}
m_Name:
m_EditorClassIdentifier:
<InitializeOnAwake>k__BackingField: 1
<ShowDebugLogs>k__BackingField: 1
<OptOutUsageAnalytics>k__BackingField: 0
<AutoConnectLastWallet>k__BackingField: 0
<SupportedChains>k__BackingField: ee6e060000000000
<IncludedWalletIds>k__BackingField: []
<RedirectPageHtmlOverride>k__BackingField:
<RpcOverrides>k__BackingField: []
<SecretKey>k__BackingField:
498 changes: 16 additions & 482 deletions Assets/Thirdweb/Runtime/Unity/ThirdwebManager.cs

Large diffs are not rendered by default.

639 changes: 639 additions & 0 deletions Assets/Thirdweb/Runtime/Unity/ThirdwebManagerBase.cs

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions Assets/Thirdweb/Runtime/Unity/ThirdwebManagerBase.cs.meta
40 changes: 40 additions & 0 deletions Assets/Thirdweb/Runtime/Unity/ThirdwebManagerServer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using UnityEngine;
using System.Linq;
using System.Numerics;

namespace Thirdweb.Unity
{
public class ThirdwebManagerServer : ThirdwebManagerBase
{
[field: SerializeField]
private string SecretKey { get; set; }

public new static ThirdwebManagerServer Instance
{
get => ThirdwebManagerBase.Instance as ThirdwebManagerServer;
}

protected override ThirdwebClient CreateClient()
{
if (string.IsNullOrEmpty(SecretKey))
{
ThirdwebDebug.LogError("SecretKey must be set in order to initialize ThirdwebManagerServer.");
return null;
}

return ThirdwebClient.Create(
secretKey: SecretKey,
httpClient: new CrossPlatformUnityHttpClient(),
sdkName: Application.platform == RuntimePlatform.WebGLPlayer ? "UnitySDK_WebGL" : "UnitySDK",
sdkOs: Application.platform.ToString(),
sdkPlatform: "unity",
sdkVersion: THIRDWEB_UNITY_SDK_VERSION,
rpcOverrides: (RpcOverrides == null || RpcOverrides.Count == 0)
? null
: RpcOverrides.ToDictionary(rpcOverride => new BigInteger(rpcOverride.ChainId), rpcOverride => rpcOverride.RpcUrl)
);
}

protected override string MobileRedirectScheme => "tw-server://";
}
}
11 changes: 11 additions & 0 deletions Assets/Thirdweb/Runtime/Unity/ThirdwebManagerServer.cs.meta
33 changes: 32 additions & 1 deletion Assets/Thirdweb/Runtime/Unity/ThirdwebUnityExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,44 @@
using System;
using System.Numerics;
using System.Threading.Tasks;
using UnityEngine;
using ZXing;
using ZXing.QrCode;

#if UNITY_WEBGL
using System.Runtime.InteropServices;
#endif

namespace Thirdweb.Unity
{
public static class ThirdwebUnityExtensions
{
#if UNITY_WEBGL
[DllImport("__Internal")]
private static extern string ThirdwebCopyBuffer(string text);
#endif

public static void CopyToClipboard(this string text)
{
try
{
if (Application.platform == RuntimePlatform.WebGLPlayer)
{
#if UNITY_WEBGL
ThirdwebCopyBuffer(text);
#endif
}
else
{
GUIUtility.systemCopyBuffer = text;
}
}
catch (Exception e)
{
ThirdwebDebug.LogWarning($"Failed to copy to clipboard: {e}");
}
}

public static async Task<Sprite> GetNFTSprite(this NFT nft, ThirdwebClient client)
{
var bytes = await nft.GetNFTImageBytes(client);
@@ -25,7 +56,7 @@ public static async Task<Sprite> GetNFTSprite(this NFT nft, ThirdwebClient clien

public static async Task<SmartWallet> UpgradeToSmartWallet(this IThirdwebWallet personalWallet, BigInteger chainId, SmartWalletOptions smartWalletOptions)
{
return await ThirdwebManager.Instance.UpgradeToSmartWallet(personalWallet, chainId, smartWalletOptions);
return await ThirdwebManagerBase.Instance.UpgradeToSmartWallet(personalWallet, chainId, smartWalletOptions);
}

public static Texture2D ToQRTexture(this string textForEncoding, Color? fgColor = null, Color? bgColor = null, int width = 512, int height = 512)
64 changes: 44 additions & 20 deletions Assets/Thirdweb/Runtime/Unity/Wallets/Core/MetaMaskWallet.cs
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ namespace Thirdweb.Unity
public class MetaMaskWallet : IThirdwebWallet
{
public ThirdwebClient Client => _client;
public string WalletId => "metamask";
public ThirdwebAccountType AccountType => ThirdwebAccountType.ExternalAccount;

private static ThirdwebClient _client;
@@ -38,20 +39,18 @@ public static async Task<MetaMaskWallet> Create(ThirdwebClient client, BigIntege
{
ThirdwebDebug.Log("MetaMask already initialized.");
await mmWallet.SwitchNetwork(activeChainId);
return mmWallet;
}
else
{
if (metaMaskInstance.IsMetaMaskAvailable())
{
ThirdwebDebug.Log("MetaMask is available. Enabling Ethereum...");
var isEnabled = await metaMaskInstance.EnableEthereumAsync();
var isEnabled = await metaMaskInstance.EnableEthereumAsync(activeChainId);
ThirdwebDebug.Log($"Ethereum enabled: {isEnabled}");
if (isEnabled && !string.IsNullOrEmpty(metaMaskInstance.GetAddress()))
{
ThirdwebDebug.Log("MetaMask initialized successfully.");
await mmWallet.SwitchNetwork(activeChainId);
return mmWallet;
}
else
{
@@ -63,6 +62,8 @@ public static async Task<MetaMaskWallet> Create(ThirdwebClient client, BigIntege
throw new Exception("MetaMask is not available.");
}
}
Utils.TrackConnection(mmWallet);
return mmWallet;
}

#region IThirdwebWallet
@@ -116,19 +117,32 @@ public async Task<string> SendTransaction(ThirdwebTransactionInput transaction)
Method = "eth_sendTransaction",
Params = new object[]
{
new TransactionInput()
{
Nonce = transaction.Nonce,
From = await GetAddress(),
To = transaction.To,
Gas = transaction.Gas,
GasPrice = transaction.GasPrice,
Value = transaction.Value,
Data = transaction.Data,
MaxFeePerGas = transaction.MaxFeePerGas,
MaxPriorityFeePerGas = transaction.MaxPriorityFeePerGas,
ChainId = new HexBigInteger(WebGLMetaMask.Instance.GetActiveChainId()),
}
transaction.GasPrice == null
? new
{
nonce = transaction.Nonce.HexValue,
from = await GetAddress(),
to = transaction.To,
gas = transaction.Gas.HexValue,
value = transaction.Value?.HexValue ?? "0x0",
data = transaction.Data,
maxFeePerGas = transaction.MaxFeePerGas.HexValue,
maxPriorityFeePerGas = transaction.MaxPriorityFeePerGas?.HexValue ?? "0x0",
chainId = WebGLMetaMask.Instance.GetActiveChainId().NumberToHex(),
type = "0x2"
}
: new
{
nonce = transaction.Nonce.HexValue,
from = await GetAddress(),
to = transaction.To,
gas = transaction.Gas.HexValue,
value = transaction.Value?.HexValue ?? "0x0",
data = transaction.Data,
gasPrice = transaction.GasPrice.HexValue,
chainId = WebGLMetaMask.Instance.GetActiveChainId().NumberToHex(),
type = "0x0"
}
}
};
return await WebGLMetaMask.Instance.RequestAsync<string>(rpcRequest);
@@ -191,10 +205,18 @@ public Task<string> RecoverAddressFromTypedDataV4<T, TDomain>(T data, TypedData<
throw new NotImplementedException();
}

public Task Disconnect()
public async Task Disconnect()
{
ThirdwebDebug.Log("Disconnecting has no effect on this wallet.");
return Task.CompletedTask;
try
{
_ = await WebGLMetaMask.Instance.RequestAsync<string>(
new RpcRequest { Method = "wallet_revokePermissions", Params = new object[] { new Dictionary<string, object> { { "eth_accounts", new object() } } } }
);
}
catch
{
// no-op
}
}

public Task<List<LinkedAccount>> LinkAccount(
@@ -206,7 +228,9 @@ public Task<List<LinkedAccount>> LinkAccount(
IThirdwebBrowser browser = null,
BigInteger? chainId = null,
string jwt = null,
string payload = null
string payload = null,
string defaultSessionIdOverride = null,
List<string> forceWalletIds = null
)
{
throw new InvalidOperationException("LinkAccount is not supported by external wallets.");
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ namespace Thirdweb.Unity
public class WalletConnectWallet : IThirdwebWallet
{
public ThirdwebClient Client => _client;

public string WalletId => "walletconnect";
public ThirdwebAccountType AccountType => ThirdwebAccountType.ExternalAccount;

protected ThirdwebClient _client;
@@ -35,7 +35,7 @@ protected WalletConnectWallet(ThirdwebClient client)
_client = client;
}

public async static Task<WalletConnectWallet> Create(ThirdwebClient client, BigInteger initialChainId, BigInteger[] supportedChains)
public async static Task<WalletConnectWallet> Create(ThirdwebClient client, BigInteger initialChainId, BigInteger[] supportedChains, string[] includedWalletIds)
{
var eip155ChainsSupported = new string[] { };
if (supportedChains != null)
@@ -44,6 +44,7 @@ public async static Task<WalletConnectWallet> Create(ThirdwebClient client, BigI
_exception = null;
_isConnected = false;
_supportedChains = eip155ChainsSupported;
_includedWalletIds = includedWalletIds;

if (WalletConnect.Instance != null && WalletConnect.Instance.IsConnected)
{
@@ -91,7 +92,9 @@ public async static Task<WalletConnectWallet> Create(ThirdwebClient client, BigI
_walletConnectService = new WalletConnectServiceCore(WalletConnect.Instance.SignClient);
}

return new WalletConnectWallet(client);
var wcw = new WalletConnectWallet(client);
Utils.TrackConnection(wcw);
return wcw;
}

public async Task SwitchNetwork(BigInteger chainId)
@@ -270,7 +273,9 @@ public Task<List<LinkedAccount>> LinkAccount(
IThirdwebBrowser browser = null,
BigInteger? chainId = null,
string jwt = null,
string payload = null
string payload = null,
string defaultSessionIdOverride = null,
List<string> forceWalletIds = null
)
{
throw new InvalidOperationException("LinkAccount is not supported by external wallets.");
3 changes: 2 additions & 1 deletion Assets/Thirdweb/Runtime/Unity/Wallets/Core/WebGLMetaMask.cs
Original file line number Diff line number Diff line change
@@ -67,8 +67,9 @@ private void Awake()
}
}

public async Task<bool> EnableEthereumAsync()
public async Task<bool> EnableEthereumAsync(BigInteger chainId)
{
_activeChainId = chainId;
_enableEthereumTaskCompletionSource = new TaskCompletionSource<bool>();

#if UNITY_WEBGL && !UNITY_EDITOR
31 changes: 31 additions & 0 deletions Assets/Thirdweb/Runtime/Unity/WebGL/WebGLCopyBuffer.jslib
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
mergeInto(LibraryManager.library, {
ThirdwebCopyBuffer: function (textPtr) {
var text = UTF8ToString(textPtr);

if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard
.writeText(text)
.then(function () {
console.log("Copied to clipboard:", text);
})
.catch(function (err) {
console.warn("Failed to copy text with navigator.clipboard:", err);
fallbackCopyText(text);
});
} else {
fallbackCopyText(text);
}

function fallbackCopyText(textToCopy) {
var input = document.createElement("textarea");
input.value = textToCopy;
input.style.position = "absolute";
input.style.left = "-9999px";
document.body.appendChild(input);
input.select();
document.execCommand("copy");
document.body.removeChild(input);
console.log("Copied to clipboard using fallback:", textToCopy);
}
},
});
32 changes: 32 additions & 0 deletions Assets/Thirdweb/Runtime/Unity/WebGL/WebGLCopyBuffer.jslib.meta
2 changes: 1 addition & 1 deletion ProjectSettings/ProjectSettings.asset
Original file line number Diff line number Diff line change
@@ -141,7 +141,7 @@ PlayerSettings:
loadStoreDebugModeEnabled: 0
visionOSBundleVersion: 1.0
tvOSBundleVersion: 1.0
bundleVersion: 5.13.1
bundleVersion: 5.22.0
preloadedAssets: []
metroInputSource: 0
wsaTransparentSwapchain: 0
111 changes: 49 additions & 62 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,52 @@
![Thirdweb Unity SDK](https://github.com/thirdweb-dev/unity-sdk/assets/43042585/0eb16b66-317b-462b-9eb1-9425c0929c96)

[<img alt="Unity Documentation" src="https://img.shields.io/badge/Unity-Documentation-blue?logo=unity&style=for-the-badge" height="30">](https://portal.thirdweb.com/unity/v5)
[<img alt=".NET Documentation" src="https://img.shields.io/badge/.NET-Documentation-purple?logo=dotnet&style=for-the-badge" height="30">](https://portal.thirdweb.com/dotnet)
<p align="center">
<strong>All-In-One Cross-Platform Blockchain Unity SDK for Browser, Standalone, Mobile and Server Targets.</strong>
</p>

<p align="center">
<a href="https://portal.thirdweb.com/unity/v5">
<img alt="Unity Documentation" src="https://img.shields.io/badge/Unity-Documentation-blue?logo=unity&style=for-the-badge" height="30">
</a>
<a href="https://portal.thirdweb.com/dotnet">
<img alt=".NET Documentation" src="https://img.shields.io/badge/.NET-Documentation-purple?logo=dotnet&style=for-the-badge" height="30">
</a>
</p>

# Technical Demo

Experience our multichain game demo leveraging In-App Wallets and Account Abstraction built in three weeks - [Web3 Warriors](https://web3warriors.thirdweb.com/).

![image](https://github.com/thirdweb-dev/unity-sdk/assets/43042585/171198b2-83e7-4c8a-951b-79126dd47abb)

# Features

This SDK provides a Unity-first integration of all [thirdweb](https://thirdweb.com) functionality, including but not limited to:

- Support for all target platforms, Unity 2022 & Unity 6.
- First party support for [In-App Wallets](https://portal.thirdweb.com/connect/wallet/overview) (Guest, Email, Phone, Socials, Custom Auth+).
- First party support for [Account Abstraction](https://portal.thirdweb.com/connect/account-abstraction/overview) (Both EIP-4337 & zkSync Native AA).
- Instant connection to any chain with RPC Edge integration.
- Integrated IPFS upload/download.
- Create blockchain-powered agents with Thirdweb [Nebula](https://thirdweb.com/nebula).
- Easy to extend or wrap.
- High level contract extensions for interacting with common standards and thirdweb contract standards.
- Automatic ABI resolution.
- Build on top of thirdweb's [.NET SDK](https://portal.thirdweb.com/dotnet) - unity package updates are typically updates to a single DLL/a file or two.
- Get started in 5 minutes with a simple [ThirdwebManager](https://portal.thirdweb.com/unity/v5/thirdwebmanager) prefab.

# Supported Platforms & Wallets

**Build games for WebGL, Desktop, and Mobile using 1000+ supported chains, with various login options!**
**Build games for Web, Standalone, and Mobile using 2000+ supported chains, with various login options!**

| Wallet Provider | WebGL | Desktop | Mobile |
| ----------------------------------------- | :---: | :-----: | :----: |
| **In-App Wallet** (Email, Phone, Socials, Custom) | ✔️ | ✔️ | ✔️ |
| **Ecosystem Wallet** (IAW w/ partner permissions) | ✔️ | ✔️ | ✔️ |
| **Private Key Wallet** (Guest Mode) | ✔️ | ✔️ | ✔️ |
| **Wallet Connect Wallet** (400+ Wallets) | ✔️ | ✔️ | ✔️ |
| **MetaMask Wallet** (Browser Extension) | ✔️ |||
| **Smart Wallet** (Account Abstraction) | ✔️ | ✔️ | ✔️ |
| Wallet Provider | Web | Standalone | Mobile |
| ------------------------------------------------------------ | :---: | :-----: | :----: |
| **In-App Wallet** (Guest, Email, Phone, Socials, Backend, Custom) | ✔️ | ✔️ | ✔️ |
| **Ecosystem Wallet** (IAW w/ partner permissions) | ✔️ | ✔️ | ✔️ |
| **Private Key Wallet** (Ephemereal, good for testing) | ✔️ | ✔️ | ✔️ |
| **Wallet Connect Wallet** (400+ Wallets) | ✔️ | ✔️ | ✔️ |
| **MetaMask Wallet** (Browser Extension) | ✔️ |||
| **Smart Wallet** (Account Abstraction: 4337, ZkSync Native, 7702) | ✔️ | ✔️ | ✔️ |

<sub>✔️ Supported</sub> &nbsp; <sub>❌ Not Supported</sub> &nbsp; <sub>— Not Applicable</sub>

@@ -30,63 +56,24 @@ Experience our multichain game demo leveraging In-App Wallets and Account Abstra
2. **Explore:** Try out `Scene_Playground` to explore functionality and get onboarded.
3. **Learn:** Explore the [Unity v5 SDK Docs](https://portal.thirdweb.com/unity/v5) and the [.NET SDK Docs](https://portal.thirdweb.com/dotnet) to find a full API reference.

**Notes:**
## Miscellaneous

- Tested on Unity 2021.3+, 2022.3+, Unity 6 Preview. We recommend using 2022 LTS.
- Newtonsoft and EDM4U are included utilities; deselect if already installed to avoid conflicts.
- Recommended Unity Editor Version: 2022.3+ (LTS)
- Newtonsoft.Json and EDM4U are included utilities; deselect when importing if already installed to avoid conflicts.
- If using .NET Framework and encountering `HttpUtility` errors, create `csc.rsp` with `-r:System.Web.dll` under `Assets`.
- Use version control and test removing duplicate DLLs if conflicts arise.
- Use version control and test removing duplicate DLLs if conflicts arise. Our SDK generally works with most versions of the few dependencies we do include.
- To use your own WalletConnect Project ID, edit `Assets/Thirdweb/Plugins/WalletConnectUnity/Resources/WalletConnectProjectConfig.asset`.

# Build Instructions

## General

- **Build Settings:** Use `Smaller (faster) Builds` / `Shorter Build Time`.
- **Player Settings:** Use IL2CPP over Mono when available.
- **Stripping Level:** Set `Managed Stripping Level` to `Minimal` (`Player Settings` > `Other Settings` > `Optimization`). (Generally not a hard requirement unless using WalletConnect as a wallet provider option.)
- **Strip Engine Code:** Make sure this is turned off.

## WebGL

- **WebGL Template:** None enforced, feel free to customize!
- **Compression Format:** Set to `Disabled` (`Player Settings` > `Publishing Settings`) for final builds.
- **Testing WebGL Social Login Locally:** Host the build or run it locally with `Cross-Origin-Opener-Policy` set to `same-origin-allow-popups`.

Example setup for testing In-App or Ecosystem Wallet Social Login locally (no longer required with Unity 6 Web, can use Build & Run):

```javascript
// YourWebGLOutputFolder/server.js
const express = require("express");
const app = express();
const port = 8000;

app.use((req, res, next) => {
res.header("Cross-Origin-Opener-Policy", "same-origin-allow-popups");
next();
});

app.use(express.static("."));
app.listen(port, () =>
console.log(`Server running on http://localhost:${port}`)
);

// run it with `node server.js`
```

No action needed for hosted builds.

## Mobile

- **EDM4U:** Comes with the package, resolves dependencies at runtime. Use `Force Resolve` from `Assets` > `External Dependency Manager` > `Android Resolver`.
- **Redirect Schemes:** Set custom schemes matching your bundle ID in `Plugins/AndroidManifest.xml` or equivalent to ensure OAuth redirects.
## Additional Resources

# Migration from v4
- [Documentation](https://portal.thirdweb.com/unity/v5)
- [Templates](https://thirdweb.com/templates)
- [Website](https://thirdweb.com)

See https://portal.thirdweb.com/unity/v5/migration-guide
## Support

# Need Help?
For help or feedback, please [visit our support site](https://thirdweb.com/support)

For any questions or support, visit our [Support Portal](https://thirdweb.com/support).
## Security

Thank you for trying out the Thirdweb Unity SDK!
If you believe you have found a security vulnerability in any of our packages, we kindly ask you not to open a public issue; and to disclose this to us by emailing `security@thirdweb.com`.