Display all NFTs In Unity

I am having some issues, I logged in to moralis using my wallet, and now I want to display all the NFTs I have in my wallet on some pannel in unity, How can I fetch the NFTs data in Unity and How can I use the NFT image to display on Panel in unity, Please help anyone.

@0xprof @glad :raised_hands:

https://docs.moralis.io/moralis-dapp/web3-api/account#getnfts

An example of how to make them render will be here


unlike the example in the docs, this project is deprecated and contains alot of invalid syntax (old moralis unity sdk version), you can use the render nft part along with the syntax on the docs for fetching the nft to render

I checked this, but what exactly do I need to extract chain id and other details from the database and then pass that into the parameters instead of directly adding the address.

which details from the database ?
you can use the connected user address and any chain

okay, thanks for your reply I’ll try and check what can I do…

@0xprof actually I am trying to fetch all the nfts that are in my wallet and want to display them in unity…I checked the above methods but there seems to be something I am not getting correctly, how should I add all those nft metadata from my wallet to moralis database, so that I can fetch them in unity…If you have any working code or example please help.

you can place them in the db, but you dont need them there, you can fetch using the web3api and then displaythem, but if you cant to fetch and place them in the db, it is fairly the same process, you can fetch and then push it to the db and then displythem from the db


https://docs.moralis.io/moralis-dapp/database/objects

Hi,

I am essentialy trying to populate an nft inventory system on top of the mmorg project but Im getting stuck at the first step. I am confused as the web3 sign in and photon are working great.

Im trying to add the example Unity code snippet posted above “https://docs.moralis.io/moralis-dapp/web3-api/account#getnfts” to the " Web3 MMORPG Example Demo" in Unity but im getting an error “CS0246: The type or namespace name ‘MoralisUnity’ could not be found”.

I have used the similar inventory functionality in the other project " Build an In-Game Unity NFT Shop" and it compiles and works fine.

Im not sure if im using the wrong sdk or if ones not compatible with another but any advice would be appreciated.

That snippet is for SDK versions 1.2.0 or newer.

You can use the older

using System.Collections.Generic;
using Moralis.Web3Api.Models;
using MoralisWeb3ApiSdk;

  public async void fetchNFTs()
  {
    NftOwnerCollection polygonNFTs = await MoralisInterface.GetClient().Web3Api.Account.GetNFTs("0x75e3e9c92162e62000425c98769965a76c2e387a".ToLower(), ChainList.polygon);
    print(polygonNFTs.ToJson());
  }

okay thankyou so much, I will give that a try tomorrow and let you know how it goes

so the code does compile now as I was trying to use the older version of the SDK, now for the fun part of trying to add a nft display method to my ui panel

out of curiosity, should I be okay to continue build and publish my project on a previous sdk or is the newer version recommened? If so, it would be really helpful if the dev’s could update the Unity boilerplate projects to work with the latest sdk version

It is recommended you use the newer SDK if you are able to migrate existing/older code over, and for new projects.

ah okay thankyou I will use the newer sdk, the video is also very helpfull

how to do for any chain user used while login with metamask

You can use getNFTs.

public async void fetchNFTs()
    {
        NftOwnerCollection polygonNFTs = await Moralis.Web3Api.Account.GetNFTs("0x75e3e9c92162e62000425c98769965a76c2e387a".ToLower(), ChainList.polygon);
        Debug.Log(polygonNFTs.ToJson());
    }

This is an example you can look at to get the current wallet address.

This gets the detail but I am not able to fetch any image from this method…can you please if possible explain in detail…

Hi @Shubham I go over what you’re requesting in this tutorial right here:

I was following the same tutorial but have few differences that make all issue I guess.

  1. I don’t have minted nfts, all the nfts are in my wallet
  2. So there’s no shop inventory, I fetched the nfts with moralis function shown in tutorial, but then not able to display it.

What I did use the same code and fetch the nft detail but my nfts are not showing, please help me in detail if possible.

I want to make user login with metamask, then on some pannel all nfts present in person’s wallet should be displayed.

@dpradell please help

1 Like