Links

Unity

Before using, please review the prerequisites
All unity SDKs are open source, click here to view

Init

It is required before call other method, you can define your app info as a metadata or user the default value, metadata is used for wallet connect.
var metadata = DAppMetadata.Create("Particle Connect",
"https://connect.particle.network/icons/512.png",
"https://connect.particle.network");
ChainInfo chainInfo = new AvalancheChain(AvalancheChainId.Mainnet);
// Init and set default chain info.
ParticleNetwork.Init(chainInfo);
ParticleConnectInteraction.Init(chainInfo, metadata);
// There are some methods use cases, that can call after init.
// Set support chain info array. you can set a chain info array.
// Default value is support all chains.
ParticleWalletGUI.SupportChain(new []{chainInfo});
// Disable buy
ParticleWalletGUI.EnablePay(false);
// Disable testnet if release
ParticleWalletGUI.ShowTestNetwork(false);
// Disable wallet manage page if you only support one wallet
ParticleWalletGUI.ShowManageWallet(false);
// Use this method to control dark mode or light mode. you can call this method with your button.
ParticleWalletGUI.SetInterfaceStyle(UserInterfaceStyle.DARK);
public void NavigatorWallet()
{
// If you want to navigator wallet token, set display to 0
// If you want to navigator wallet NFT, set display to 1
int display = 0;
ParticleWalletGUI.NavigatorWallet(display);
}
public void NavigatorTokenReceive()
{
// If you want to test solana, your should replace under value with solana test account.
// Navigator to token receive page
// This is ChainLink Token in Ethereum Gnerli
string tokenAddress = TestAccount.EVM.TokenContractAddress;
ParticleWalletGUI.NavigatorTokenReceive(tokenAddress);
}
public void NavigatorTokenSend()
{
// If you want to test solana, your should replace under value with solana test account.
// This is ChainLink Token in Ethereum Gnerli
string tokenAddress = TestAccount.EVM.TokenContractAddress;
// Another receiver address
string toAddress = TestAccount.EVM.ReceiverAddress;
// Send amount
string amount = "1000000000";
ParticleWalletGUI.NavigatorTokenSend(tokenAddress, toAddress, amount);
}
public void NavigatorTokenTransactionRecords()
{
// If you want to test solana, your should replace under value with solana test account.
// This is ChainLink Token in Ethereum Gnerli
string tokenAddress = TestAccount.EVM.TokenContractAddress;
ParticleWalletGUI.NavigatorTokenTransactionRecords(tokenAddress);
}
public void NavigatorNFTSend()
{
// If you want to test solana, your should replace under value with solana test account.
// This is a test NFT
string mint = TestAccount.EVM.NFTContractAddress;
string tokenId = TestAccount.EVM.NFTTokenId;
string receiveAddress = "";
ParticleWalletGUI.NavigatorNFTSend(mint, tokenId, receiveAddress);
}
public void NavigatorNFTDetails()
{
// If you want to test solana, your should replace under value with solana test account.
// This is a test NFT
string mint = TestAccount.EVM.NFTContractAddress;
string tokenId = TestAccount.EVM.NFTTokenId;
ParticleWalletGUI.NavigatorNFTDetails(mint, tokenId);
}
public void NavigatorBuyCrypto()
{
// buy crypto with parameters
BuyCryptoConfig config = new BuyCryptoConfig(TestAccount.EVM.PublicAddress,
OpenBuyNetwork.BinanceSmartChain, "BNB", "USD", 100);
ParticleWalletGUI.NavigatorBuyCrypto(config);
// also support buy crypto without parameters
ParticleWalletGUI.NavigatorBuyCrypto();
}
public async void NavigatorLoginList()
{
var nativeResultData = await ParticleWalletGUI.Instance.NavigatorLoginList();
if (nativeResultData.isSuccess)
{
Debug.Log(nativeResultData.data);
}
else
{
var errorData = JsonConvert.DeserializeObject<NativeErrorData>(nativeResultData.data);
Debug.Log(errorData);
}
}
public void NavigatorSwap()
{
ParticleWalletGUI.NavigatorSwap();
}

Switch Wallet

You'd better call this method to sync wallet with GUI, before open any GUI page.
For example, user connects more than one wallet, then open wallet page, call this method to make sure open this right wallet in GUI pages.
public async void SwitchWallet()
{
var walletType = WalletType.MetaMask;
var publicAddress = "";
var nativeResultData = await ParticleWalletGUI.Instance.SwitchWallet(walletType, publicAddress);
Debug.Log(nativeResultData.data);
if (nativeResultData.isSuccess)
{
ShowToast($"{MethodBase.GetCurrentMethod()?.Name} Success:{nativeResultData.data}");
Debug.Log(nativeResultData.data);
}
else
{
ShowToast($"{MethodBase.GetCurrentMethod()?.Name} Failed:{nativeResultData.data}");
var errorData = JsonConvert.DeserializeObject<NativeErrorData>(nativeResultData.data);
Debug.Log(errorData);
}
}

Set support chain infos, default value is support all chain infos.

ChainInfo avalanche = new AvalancheChain(AvalancheChainId.Mainnet);
ChainInfo ethereum = new EthereumChain(EthereumChainId.Mainnet);
ChainInfo bsc = new BSCChain(BscChainId.Mainnet);
ParticleWalletGUI.SupportChain(new []{avalanche, bsc, ethereum});

Set enable or disable swap feature, default value is true.

ParticleWalletGUI.EnableSwap(true);

Set enable or disable buy crypto feature, default value is true.

ParticleWalletGUI.EnablePay(true);

Set show or hidden test network in switch network page, default value is false.

ParticleWalletGUI.ShowTestNetwork(false);

Set show or hidden wallet manage page, default value is true.

ParticleWalletGUI.ShowManageWallet(false);

Set user interface style, default value is follow system.

ParticleNetwork.SetInterfaceStyle(UserInterfaceStyle.DARK);

Set language, default value is follow system.

ParticleWalletGUI.SetLanguage(Language.EN);

Get swap enabled state

public void GetSwapEnableState()
{
var result = ParticleWalletGUI.GetEnableSwap();
Debug.Log($"Swap enable state = {result}");
}

Get buy crypto enabled state

public void GetBuyCryptoEnableState()
{
var result = ParticleWalletGUI.GetEnablePay();
Debug.Log($"Buy crypto enable state = {result}");
}
Last modified 1d ago