Skip to content

Sandbox Developers SDK — Usage Examples

This page provides basic examples on how to use the SandboxSDK in your project.


1. Initialization and Authentication

csharp
using Sandbox.Developers;

void Start()
{
    OAuthSettings settings = new OAuthSettings
    {
        clientId = "your-client-id",
		clientSecret = "your-client-secret";
        redirectUri = "your-redirect-uri"
    };

    SandboxSDK.Initialize(settings);
    await SandboxSDK.RequestAuthorization();
}

2. Get Logged User Info

csharp
string userId = SandboxSDK.GetLoggedUserId();
UserResponse user = await SandboxSDK.GetUser(userId);
Debug.Log($"User Name: {user.name}");

3. Fetch Public Assets

csharp
AssetsResponse assets = await SandboxSDK.GetPublicAssets(limit: 10);
foreach (var asset in assets.items)
{
    Debug.Log($"Asset: {asset.name}");
}

4. Instantiate an Asset

csharp
SandboxAsset asset = await SandboxSDK.InstantiateAsset("asset-id");
asset.transform.position = new Vector3(0, 0, 0);

5. Preload Multiple Assets

csharp
List<string> ids = new List<string> { "asset-id-1", "asset-id-2" };
await SandboxSDK.PreloadAssets(ids, (loaded, total) => {
    Debug.Log($"Loading progress: {loaded}/{total}");
});

6. Animate an Asset

csharp
SandboxAsset asset = await SandboxSDK.InstantiateAsset("asset-id");
asset.PlayAnimation(asset.AnimationClips[0].name, true); // play the first animation clip in loop mode

Notes

  • Make sure you call Initialize() before any API call.
  • Always handle await with UniTask correctly inside an async method or UniTask.Void when needed.
  • All examples assume you are working inside a Unity project using Cysharp.Threading.Tasks.

These are minimal examples to get you started. Refer to the full API documentation for more detailed usage.