diff --git a/Runtime/ConnectPlayerWallet.cs b/Runtime/ConnectPlayerWallet.cs index 8b1847b8..468ba85b 100644 --- a/Runtime/ConnectPlayerWallet.cs +++ b/Runtime/ConnectPlayerWallet.cs @@ -1,17 +1,11 @@ - using System; using System.Runtime.InteropServices; +using UnityEngine; +using UnityEngine.Events; namespace AlturaNFT { - using UnityEngine; - using UnityEngine.Events; - using Internal; - - //[AddComponentMenu(AlturaConstants.BaseComponentMenu + AlturaConstants.FeatureName_ConnectUserWallet)] - //[HelpURL(AlturaConstants.Docs_ConnectUserWallet)] public class ConnectPlayerWallet : MonoBehaviour - { public string MockconnectedWalletAddress = "0xfb7C2D5c65e00d05C48AfF5c02C6D4682156DF33"; public string MockconnectedNetworkID = "1"; @@ -20,57 +14,55 @@ public class ConnectPlayerWallet : MonoBehaviour public string connectedNetworkID; public UnityEvent afterSuccess; - private UnityAction OnCompleteAction; - + private UnityAction OnCompleteAction; + /// - /// Initialize creates a gameobject and assings this script as a component. This must be called if it doesn't already exists in the scene on gameObject named PlayerConnect_AlturaNFT. + /// Initialize creates a gameobject and assigns this script as a component. This must be called if it doesn't already exist in the scene on a gameObject named PlayerConnect_AlturaNFT. /// public static ConnectPlayerWallet Initialize() { var _this = new GameObject("PlayerConnect_AlturaNFT").AddComponent(); return _this; } - + /// - /// Action when player successfully connects the wallet returning connected address and connected networkID + /// Action when player successfully connects the wallet, returning connected address and connected networkID. /// /// Player Wallet Address String - public ConnectPlayerWallet OnComplete(UnityAction action) + public ConnectPlayerWallet OnComplete(UnityAction action) { this.OnCompleteAction = action; return this; } - - + /// - /// Use this function on a Button from inside Unity to Connect Account, If a mock wallet is entered It'll be connected only on editor level + /// Use this function on a Button from inside Unity to Connect Account. If a mock wallet is entered, it'll be connected only on editor level. /// public void WebSend_GetAddress() { #if UNITY_EDITOR connectedWalletAddress = MockconnectedWalletAddress; connectedNetworkID = MockconnectedNetworkID; - + User.ConnectedPlayerAddress = connectedWalletAddress; User.ConnectedPlayerNetworkID = connectedNetworkID; - Debug.Log("Editor Mock Wallet Connected , Address: " + User.ConnectedPlayerAddress + " at Network ID:" + User.ConnectedPlayerNetworkID +" | Access it via User.ConnectedPlayerAddress"); + Debug.Log("Editor Mock Wallet Connected, Address: " + User.ConnectedPlayerAddress + " at Network ID:" + User.ConnectedPlayerNetworkID + " | Access it via User.ConnectedPlayerAddress"); GetAddressSuccess(); #endif } - + void Awake() { - #if UNITY_EDITOR User.ConnectedPlayerAddress = connectedWalletAddress; User.ConnectedPlayerNetworkID = connectedNetworkID; #endif - + this.gameObject.name = "PlayerConnect_AlturaNFT"; } /// - /// Use this to hook up other wallet connect features to AlturaNFT wallet connect to access User.connectedplayeraddress + /// Use this to hook up other wallet connect features to AlturaNFT wallet connect to access User.connectedplayeraddress. /// /// public void ConnectThisToAlturaNFTWalletConnect(string connectedWalletAddress) @@ -78,30 +70,33 @@ public void ConnectThisToAlturaNFTWalletConnect(string connectedWalletAddress) WebHook_GetAddress(connectedWalletAddress); } - //called from index - For WebGL + // Called from index - For WebGL public void WebHook_GetNetworkID(string networkID) { User.ConnectedPlayerNetworkID = networkID; connectedNetworkID = networkID; - } - - //called from index - For WebGL - public void WebHook_GetAddress(string recievedaddress) + + // Called from index - For WebGL + public void WebHook_GetAddress(string receivedAddress) { - connectedWalletAddress = recievedaddress; + connectedWalletAddress = receivedAddress; User.ConnectedPlayerAddress = connectedWalletAddress; GetAddressSuccess(); } void GetAddressSuccess() { - if(OnCompleteAction!=null) - OnCompleteAction.Invoke(connectedWalletAddress,User.ConnectedPlayerNetworkID ); - - if(afterSuccess!=null) - afterSuccess.Invoke(); + OnCompleteAction?.Invoke(connectedWalletAddress, User.ConnectedPlayerNetworkID); + afterSuccess?.Invoke(); } - + +#if UNITY_WEBGL + [DllImport("__Internal")] + public static extern string SendCallTo_GetAddress(); +#else + [DllImport("AlturaNFTConnectUser.jslib")] + public static extern string SendCallTo_GetAddress(); +#endif } -} \ No newline at end of file +} diff --git a/package.json b/package.json index 9f40c71c..ed9188d6 100644 --- a/package.json +++ b/package.json @@ -1,30 +1,30 @@ { "name": "com.alturaweb3.sdk", - "version": "1.0.6", + "version": "1.0.7", "displayName": "Altura Web3", "description": "This Web3 Package connects to the Altura APIs to help you authenticate and communicate with the Blockchain from Unity", "dependencies": { - "com.unity.nuget.newtonsoft-json": "3.0.2" + "com.unity.nuget.newtonsoft-json": "3.2.1" }, "keywords": [ - "web3", - "api", - "nft" + "web3", + "api", + "nft" ], "author": { - "name": "AlturaNFT", - "email": "team@alturanft.com", - "url": "https://www.alturanft.com" + "name": "AlturaNFT", + "email": "team@alturanft.com", + "url": "https://www.alturanft.com" }, "samples": [ - { - "displayName":"AlturaDemo", - "description": "Altura API Data", - "path": "Altura-Sample~/AlturaDemo" - } + { + "displayName": "AlturaDemo", + "description": "Altura API Data", + "path": "Altura-Sample~/AlturaDemo" + } ], "type": "tool", - "unity": "2019.4", + "unity": "2022.3", "hideInEditor": false, "license": "See LICENSE.md file" }