Unity webgl nfts

Hi, I’m on v1 I believe, but anyways the api calls work. I’m having wallet login with QR, then if you own an NFT from a particular collection, all the traits are loaded as game objects.
I use the get NFTs by contact moralis provides, and yes it seems all opensea.io lazy mints share the same contract address which sucks.
Now I iterate through foreach(nft as noc.Result),it iterates fine through them, finds my nft, if it’s the first and only nft in the wallet. If there is more than one nft (example I have a wallet that iterates past 2 other NFTs before reaching the one I’m looking for) it lists them in the log, and loads the traits fine in Unity editor, but in WebGL build it crashes with an ugly stacktrace. Again, the wallet with a single nft from searched collection loads everything fine, but more than one nft and CRASHHHH! Stacktrace says something about a connection to an url being interrupted. I attached my GetNft.cs script to the user player, so as the player is loaded it’s called. I’ve alao tried putting the code in PhotonPlayerController.cs and GameManager.cs, same results.
I thought I’d get my question on how to fix this to you guys, as you’re WAY smarter than me.
I’m planning to make a development build and see if that helps me chase errors in browser, and I’m going to try making a trigger once player moves off initial position to see if it helps.
What’s interruption the loading when a second nft is iterated?
I’ll provide whatever logs/code you ask for. I really want this to work.
Thank you

Update: I’ve figured it out, async void is horrible with webgl, as it all runs on a single thread.
So I broke up bits and parts (GetUserSync, GetNFTsForContract,…) into async Task instead, along with a bool check if noc (variable holding moralis response data) is null or not, basically, I run the moralis Tasks to fetch data in Start() then call my SetNFTtraits() with a condition (if noc is null, skip. If not, do and set bool to true).
Anyone working with this frustrated crap will understand the terms I’ve used I hope.
Btw LOVE MORALIS! Unity, on the other hand… :rofl:

Hi could you post your code in case someone has a similar issue.

Of Course! Here’s Start and Update:

private void Start()
            boolll = false;
private void Update()
            if (boolll == false)

Then the SetUserTraits I did as IEnumerator:

IEnumerator SetUserTraits()
                    // do nothing
                } else {
                           if (boolll==false){
                                 // do your stuff ie: foreach(NftOwner nft in noc.Result){ }
                boolll = true;
                return new WaitForSeconds(0.0f); // or if you want set a time to wait

And then the Tasks that you need if async void is failing you, though my putting a bool and Start()/Update() likely remedies this (I stuck with Task anyways):

private async Task SetUserAddr()
            var user = await MoralisInterface.GetUserAsync();
            addr = user.authData["moralisEth"]["id"].ToString();
private async Task SetUserNfts()
            noc =
                    await MoralisInterface.GetClient().Web3Api.Account.GetNFTsForContract(addr,


1 Like

@davecotefilm can you please tell me how did you load all the traits as game objects ? i really need your help… My email id - [email protected]
this line:-

then if you own an NFT from a particular collection, all the traits are loaded as game objects.