Skip to content
🎉 Welcome! Translations are currently experimental. | 翻訳は現在実験的です。 | 翻译目前处于实验阶段。
Click here to submit feedback! | ここをクリックしてフィードバックを送信してください! | 点击这里提交反馈!
BuildSDKs.NET SDKUnity Integration

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)

  1. Open Package Manager window (Window | Package Manager)
  2. Click + button on the upper-left of a window, and select Add package from git URL…
  3. 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

  1. Go to the aptos-labs/unity-sdk Releases and download the latest release.
  2. 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 AptosUnityClient(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.