❗
This integration is currently in beta. Please report any issues you encounter by creating an issue in the aptos-labs/aptos-dotnet-sdk repository.
Integrating into Unity projects
This guide will walk you through the process of integrating the Aptos .NET SDK.
Install the Aptos Unity SDK
Option 1: Import via Unity Package Manager (UPM)
- Open Package Manager window (Window | Package Manager)
- Click + button on the upper-left of a window, and select Add package from git URL…
- Enter the following URL and click Add button
https://github.com/aptos-labs/unity-sdk.git?path=/Packages/com.aptoslabs.aptos-unity-sdk
Option 2: Import via unitypackage
- Go to the
aptos-labs/unity-sdk Releases
and download the latest release. - Drag and drop the
.unitypackage
file into your Unity project.
Use the Aptos SDK
Import the Aptos
namespace in your C# script and use the SDK.
using UnityEngine;
using Aptos;
class Example : MonoBehaviour
{
public void Start()
{
PrintLedgerInfo();
}
async void PrintLedgerInfo() {
var client = new AptosClient(Networks.Mainnet);
var ledgerInfo = await client.Block.GetLedgerInfo();
Debug.Log(ledgerInfo.BlockHeight);
}
}
Next Steps
You’ve successfully integrated the Aptos .NET SDK into your Unity project. Now you can start building your game and interacting with the Aptos blockchain. Below are some resources to help you get started.