diff --git a/Assets/Thirdweb/Examples/Prefabs/Prefab_ConnectWallet.prefab b/Assets/Thirdweb/Examples/Prefabs/Prefab_ConnectWallet.prefab index 25b783c6..a0967b3e 100644 --- a/Assets/Thirdweb/Examples/Prefabs/Prefab_ConnectWallet.prefab +++ b/Assets/Thirdweb/Examples/Prefabs/Prefab_ConnectWallet.prefab @@ -965,7 +965,7 @@ MonoBehaviour: m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] - m_Sprite: {fileID: 21300000, guid: 874d8401331ede14087e8d8d486ddda6, type: 3} + m_Sprite: {fileID: 21300000, guid: 4a851c149a30f1e4b8088ab52b81444d, type: 3} m_Type: 0 m_PreserveAspect: 1 m_FillCenter: 1 @@ -2145,7 +2145,7 @@ MonoBehaviour: m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] - m_Sprite: {fileID: 21300000, guid: 6d6088174bb906b49ad8428526ee337b, type: 3} + m_Sprite: {fileID: 21300000, guid: 97e254ea33741df4686d7097f9d1435b, type: 3} m_Type: 0 m_PreserveAspect: 1 m_FillCenter: 1 @@ -2286,6 +2286,15 @@ MonoBehaviour: m_EditorClassIdentifier: supportedWallets: 010000000200000003000000 supportSwitchingNetwork: 1 + OnConnectedCallback: + m_PersistentCalls: + m_Calls: [] + OnDisconnectedCallback: + m_PersistentCalls: + m_Calls: [] + OnSwitchNetworkCallback: + m_PersistentCalls: + m_Calls: [] connectButton: {fileID: 1335404547334051784} connectDropdown: {fileID: 1335404547797609896} walletButtons: diff --git a/Assets/Thirdweb/Examples/Scripts/Prefabs/Prefab_ConnectWallet.cs b/Assets/Thirdweb/Examples/Scripts/Prefabs/Prefab_ConnectWallet.cs index 220dc465..eb3cbc0b 100644 --- a/Assets/Thirdweb/Examples/Scripts/Prefabs/Prefab_ConnectWallet.cs +++ b/Assets/Thirdweb/Examples/Scripts/Prefabs/Prefab_ConnectWallet.cs @@ -4,6 +4,7 @@ using System; using TMPro; using UnityEngine.UI; +using UnityEngine.Events; public enum Wallet { @@ -35,6 +36,11 @@ public class Prefab_ConnectWallet : MonoBehaviour public List supportedWallets; public bool supportSwitchingNetwork; + [Header("CUSTOM CALLBACKS")] + public UnityEvent OnConnectedCallback; + public UnityEvent OnDisconnectedCallback; + public UnityEvent OnSwitchNetworkCallback; + [Header("UI ELEMENTS (DO NOT EDIT)")] // Connecting public GameObject connectButton; @@ -109,6 +115,8 @@ public async void OnConnect(Wallet _wallet) wallet = _wallet; OnConnected(); + if (OnConnectedCallback != null) + OnConnectedCallback.Invoke(); print($"Connected successfully to: {address}"); } catch (Exception e) @@ -150,6 +158,8 @@ public async void OnDisconnect() { await ThirdwebManager.Instance.SDK.wallet.Disconnect(); OnDisconnected(); + if (OnDisconnectedCallback != null) + OnDisconnectedCallback.Invoke(); print($"Disconnected successfully."); } @@ -178,6 +188,8 @@ public async void OnSwitchNetwork(Chain _chain) ThirdwebManager.Instance.chain = _chain; await ThirdwebManager.Instance.SDK.wallet.SwitchNetwork((int)_chain); OnConnected(); + if (OnSwitchNetworkCallback != null) + OnSwitchNetworkCallback.Invoke(); print($"Switched Network Successfully: {_chain}"); }