SuiPlay SDK for Unity
The OriginByte Unity toolset for game developers on Sui
Features
For Rpc clients’ direct interaction with the Sui JSON-RPC https://docs.sui.io/sui-jsonrpc
Read API
Write 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)
SLIP-0010 : Universal private key derivation from master private key also supported
Sign transactions
Store key pair in PlayerPrefs
Interact with Origin Byte Nft Protocol (v1.1.0) https://github.com/Origin-Byte/nft-protocol
Windows desktop and WebGL platforms tested
Unity 2021.3.10f1 LTS or later supported
Samples are using Sui v1.2.0 testnet
Please note, some of the samples and typings are being updated!
Getting Started
To start, download the repository and open with Unity:
The Samples are in ./Assets/SuiUnitySDK/Samples Open a Scene from ./Assets/SuiUnitySDK/Samples/Scenes
Installation
Choose one of the following methods:
1. Using the openupm registry, you can install it via openupm-cli:
2. Via 'Add package from git URL' in the Unity Package Manager:
3. Via git url by adding this entry in your manifest.json:
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/releasesDrag and drop the
sui-unity-sdk.unitypackage
to the Project windowAs soon as the Import Windows pop up, click the Import button
Start using the SDK via SuiApi and SuiWallet classes. You can check out some samples below:
Usage Samples
All samples can be found in SuiUnitySDK/Samples
Wallet management
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.
RPC Read API
Once entering an address, you'll be able to see the results as a formatted JSON.
RPC Move Call and Execute Transaction Samples
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.
You can find out more about this here.
Mint An NFT using the OriginByte NFT Protocol
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.
Nft loaders
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.
Capy Loader
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.
Dependencies
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"
Samples Dependencies
Dependencies used by the Samples can be found in ./Assets/SuiUnitySDK/Samples/Plugins
TextMesh Pro
WebGLCopyAndPaste
Our Roadmap
Mobile platform support (iOS, Android)
WalletConnect
Streaming RPC client, Event subscription
More samples
OriginByte NFT ecosystem access from Unity
Higher level APIs, easy-to-use Prefabs
Rust & Typescript SDK parity
Our Community
Last updated