ReadyNFT
Search
K
Comment on page

Fetch Sprites

In this tutorial, we will fetch the game sprites from the ReadyNFT Asset Hub
The FetchSpritesAsync method is used to asynchronously fetch sprite objects from the ReadyNFT API. This method retrieves information about the NFTs associated with your game, such as their IDs, names, contract addresses, images, and stats.
Note: Before calling the FetchSpritesAsync method, ensure that you have already initialised the ReadyNFT SDK by calling the Init method. Refer to our Initialising the SDK guide for an in-depth look at the same.

Method Signature

public async Task<List<ReadyNFTSpriteObject>> FetchSpritesAsync()

Return Type

Task<List<ReadyNFTSpriteObject>>
A task that represents the asynchronous fetch operation. It retrieves a list of ReadyNFTSpriteObject instances, each containing detailed information about an NFT sprite. Check out the Types section for more information about the ReadyNFTSpriteObject

Usage Example

using System.Collections.Generic;
using UnityEngine;
public class ReadyNFTManager : MonoBehaviour
{
private const string apiKey = "your-api-key";
private const string gameId = "your-game-id";
void Start()
{
InitializeReadyNFT();
}
public async void InitializeReadyNFT()
{
ReadyNFT readyNFT = new ReadyNFT();
readyNFT.Init(apiKey, gameId);
Debug.Log("ReadyNFT initialized!");
Debug.Log("Fetching sprites...");
List<ReadyNFTSpriteObject> sprites = await readyNFT.FetchSpritesAsync();
}
}
By utilising the FetchSpritesAsync method, you can retrieve detailed information about the NFT sprites associated with your game. This data can then be used to create visual representations of the NFTs or to implement various game mechanics based on the fetched sprite objects.