Unity SDK
The Unity toolset for game developers on Sui
- Read API
- Event Read API
- Transaction Builder Api
- Event streaming support
- Helper methods to build and execute transactions
- Typed move calls
- Wallet Management
- Generate and Restore key pairs with Mnemonics (currently Ed25519 supported)
- Sign transactions
- Store key pair in PlayerPrefs
- Helper Scripts and prefabs to load NFTs (even Capys!)
- Windows desktop and WebGL platforms tested
- Unity 2021.3.10f1 LTS or later supported
- Samples are using Sui 0.20.0 devnet

The Samples are in ./Assets/SuiUnitySDK/Samples
Open a Scene from ./Assets/SuiUnitySDK/Samples/Scenes
Choose one of the following methods:
openupm add com.originbyte.suiunitysdk
https://github.com/Origin-Byte/sui-unity-sdk.git#upm
"com.originbyte.suiunitysdk": "https://github.com/Origin-Byte/sui-unity-sdk.git#upm"
4. Download the latest sui-unity-sdk.unitypackage
from the releases: https://github.com/Origin-Byte/sui-unity-sdk/releases
sui-unity-sdk.unitypackage
from the releases: https://github.com/Origin-Byte/sui-unity-sdk/releases- 1.Drag and drop the
sui-unity-sdk.unitypackage
to the Project window - 2.As soon as the Import Windows pop up, click the Import button
All samples can be found in SuiUnitySDK/Samples



You can click on the
Create New Wallet
or Import Wallet
buttons to initialize the currently active Wallet.PlayerPrefs is currently used as a keystore. It saves the last active wallet and will be loaded from there on the next restart.
You are now ready to execute transactions that require signatures.
var mnemonics = SuiWallet.CreateNewWallet();
...
SuiWallet.RestoreWalletFromMnemonics(mnemonics);
var activeAddress = SuiWallet.GetActiveAddress();

Once entering an address, you'll be able to see the results as a formatted JSON.
var ownedObjectsResult = await SuiApi.Client.GetObjectsOwnedByAddressAsync(address);
Ouput.text = JsonConvert.SerializeObject(ownedObjectsResult.Result, Formatting.Indented);

This sample code calls a function in a published Move Package that has a
counter
module with an increment
function. It modifies a shared object, incrementing the counter by 1. var signer = SuiWallet.GetActiveAddress();
var packageObjectId = "0xa21da7987c2b75870ddb4d638600f9af950b64c6";
var module = "counter";
var function = "increment";
var typeArgs = System.Array.Empty<string>();
var args = new object[] { SharedCounterObjectId };
var gasObjectId = GasObjectIdInput.text;
var rpcResult = await SuiApi.Client.MoveCallAsync(signer, packageObjectId, module, function, typeArgs, args, gasObjectId, 2000);
var keyPair = SuiWallet.GetActiveKeyPair();
var txBytes = rpcResult.Result.TxBytes;
var signature = keyPair.Sign(rpcResult.Result.TxBytes);
var pkBase64 = keyPair.PublicKeyBase64;
await SuiApi.Client.ExecuteTransactionAsync(txBytes, SuiSignatureScheme.ED25519, signature, pkBase64);
...

This sample demonstrates the minting of an NFT for a collection using the OriginByte NFT protocol with RPC calls. More information on the Protocol can be found here.
In this sample we automatically query for 2 separate SUI coin type objects, as the Move call executes in a batch transaction and Sui does not allow the same coin object to be both used as gas and mutate in the Move call.
var signer = SuiWallet.GetActiveAddress();
// package id of the Nft Protocol
var packageObjectId = "0x1e5a734576e8d8c885cd4cf75665c05d9944ae34";
var module = "std_nft";
var function = "mint_and_transfer";
var typeArgs = System.Array.Empty<string>();
// We need 2 separate gas objects because both of them will be mutated in a batch transaction
var gasObjectIds = await SuiHelper.GetCoinObjectIdsAboveBalancesOwnedByAddressAsync(signer, 2);
if (gasObjectIds.Count < 2)
{
Debug.LogError("Could not retrieve 2 sui coin objects with at least 2000 balance. Please send more SUI to your address");
return;
}
var args = new object[] { NFTNameInputField.text, NFTUrlInputField.text, false, new object[] { "description" },
new object[] { NFTDescriptionInputField.text }, NFTCollectionIdInputField.text, gasObjectIds[0], signer };
NFTMintedText.gameObject.SetActive(false);
NFTMintedReadonlyInputField.gameObject.SetActive(false);
var rpcResult = await SuiApi.Client.MoveCallAsync(signer, packageObjectId, module, function, typeArgs, args, gasObjectIds[1], 2000);
if (rpcResult.IsSuccess)
{
var keyPair = SuiWallet.GetActiveKeyPair();
var txBytes = rpcResult.Result.TxBytes;
var signature = keyPair.Sign(rpcResult.Result.TxBytes);
var pkBase64 = keyPair.PublicKeyBase64;
var txRpcResult = await SuiApi.Client.ExecuteTransactionAsync(txBytes, SuiSignatureScheme.ED25519, signature, pkBase64);
}
else
{
Debug.LogError("Something went wrong with the move call: " + rpcResult.ErrorMessage);
}
Check out the NftLoaders scene. Contains samples for using Nfts as UI Image sprite, main texture of material.

Change the Ids and Address to yours.



You can also import Capys! This uses the experimental Vector Graphics package to render the SVG images as PNGs. Check out the CapyNftLoaders scene to see it in action!


It can load the whole hierarchy of accessories for the Capy, or just the main Capy object.
Every dependency used by the SDK can be found in
./Assets/SuiUnitySDK/Plugins
.NuGet packages are in
./Assets/SuiUnitySDK/Plugins/NuGetPackages
.suinet
, our internal C#/.NET Sui library. It will be regularly updated as features are added to the core library.Chaos.NaCl.Standard
Portable.BouncyCastle
Newtonsoft.Json
(included in recent Unity versions by default)com.unity.vectorgraphics
- if you got compilation errors, you need to add this entry to your .Packages/manifest.json file's dependencies section:
"com.unity.vectorgraphics": "2.0.0-preview.20"
Dependencies used by the Samples can be found in
./Assets/SuiUnitySDK/Samples/Plugins
TextMesh Pro
WebGLCopyAndPaste
- Mobile platform support (iOS, Android)
- WalletConnect
- Streaming RPC client, Event subscription
- Secp256k1 keypair support
- More samples
- OriginByte NFT ecosystem access from Unity
- Higher level APIs, easy-to-use Prefabs
- Rust & Typescript SDK parity
Last modified 2mo ago