Ethereum Unity3D Boilerplate Questions

yes I have done it multiple times and that was happening with 1.2.2 too so I updated to 1.2.3, not working either, I think it probably has to do with some other package, I have also tried reimporting, refreshing, and deleting the package from the package manager, but no luck either. will try with upgrading the project to a newer version

you can use, openzeppelin defender or biconomy I think it would save you some development time

Could not find any unity related tutorial, all are web3 dapps mostly on react.

Hey guys, does Unity Webgl Metamask login work on mobile browser? I able to login in PC browser, I wonder if it work on mobile browser as well.

If no, how to I make it work on mobile browser?

Hey @wjkang!

It also works in Android and iOS. It will use the crypto wallet that you have installed there.

Cheers

What Unity version are you using?

Hello!

Could you please give me direction on how to setup deep links ?
When I use the openMobileWallet() method it always open metamask even if the authentication has been done with a imtoken.

And openDeepLink() don’t open anything.
Any suggestion on how to proceed to get redirected to the proper wallet ?

Also, how can I reduce the number of wallet displayed in when fetching wallet list on iOs ?
There is 15 wallets popping, and this seem hard coded ?

Thanks a lot

Unity 2021.3.0f1 , already solved that issue It seems like when upgrading form 1.2.2 to 1.2.3, had to restore a previous version of the app and delete the assets and remove the package from package manager, but I have a new Issue btw, I’m retrieving multiple NFTs from multiple contracts, and I based my self on your ElderRing Inventory to do it but now I ran into this issue.

async void LoadItems(string playerAddress, List<Allowed_Contracts> contractAddresses, ChainList contractChain)
        {
            foreach (var contract in contractAddresses)

            {

                Debug.Log("contract address :" + contract.contract_address);
            }

             try {
                ClearAllItems(); // We clear the grid before adding new items

                foreach (var contract in contractAddresses)

                {
                    NftOwnerCollection noc =
                        await Moralis.GetClient().Web3Api.Account.GetNFTsForContract(playerAddress.ToLower(),
                            contract.contract_address, contractChain);

                    List<NftOwner> nftOwners = noc.Result;

                    // We only proceed if we find some


                    if (nftOwners.Count == _currentItemsCount && nftOwners.Count != 0)
                    {
                        Debug.Log("There are no new items to load");
                        return;

                    }
                    else if (!nftOwners.Any())
                    {
                        Debug.Log("You don't own items from this collection:"+contract.contract_address);

                    }
                    else
                    {
                        foreach (var nftOwner in nftOwners)
                        {
                            if (nftOwner.Metadata == null)
                            {
                                // Sometimes GetNFTsForContract fails to get NFT Metadata. We need to re-sync
                                await Moralis.GetClient().Web3Api.Token.ReSyncMetadata(nftOwner.TokenAddress, nftOwner.TokenId, contractChain);
                                Debug.Log("We couldn't get NFT Metadata. Re-syncing...");
                                continue;
                            }

                            var metadata = nftOwner.Metadata;
                            MetadataObject metadataObject = JsonUtility.FromJson<MetadataObject>(metadata);
                            Debug.Log(metadataObject.image);

                            PopulatePlayerItem(contract.contract_address, nftOwner.TokenId, metadataObject);

                           
                        }
                    }


                    _currentItemsCount = 0;

                }
            }
            catch (Exception exp)
            {
                Debug.LogError(exp.Message);
            }
        }```

but I’m getting this error is there other way to do this? that is more efficient than a nested for each or not making more than 25 rq/s to avoid hitting free tier limits

Hi there struggling with deeplink in iOS. Works well on android.
But no signature request pops up on wallets when I use deeplink on iPhone….
Been having this issue for a while no one is replying :frowning:

Hi @Hero909,

If I understand, you’re using OpenMobileWallet() and it always opens MetaMask, not the wallet that you authenticated with. Am I right?

1 Like

Hi @davidcryptocol,

Sorry but never tried getting NFTs for different contracts in a foreach loop :confused:

The code seems okay but surely this looks like an expensive method and there is no specific endpoint to do that atm.

1 Like

Hi there !

Yea this is correct ! :slight_smile:

Hey @dpradell, thanks for reply. I tried open in Android google chrome, but when I click on connect metamask button, it didn’t launch the Metamask app. Is it I need to implement the Deep Link function for webgl?

Best regards.

hi there,
Unity Package for v1.2.7 on github is missing from last update. why is that ? :slight_smile:

Hi there !
Magic Link has a new sdk for unity, now moralis allow authentification with other systems. any help on how to make compatible would be much appreciated… trying to figure out how to use both magic and moralis. Specifically running a specific function of a specific contract …
Running into some dependencies issues (doubles)
Thanks for your help!

I have downloaded web3GameKitPackagev1.2.7 unitypackage. But according to doc I can’t find moralis interface to import and InsertContractInstance method. How to import and call those ?

How to get returned value of contract function in unity ?
There is a contract function which returns uint256. And I am calling that function from unity using ExecuteContractFunction and I am getting TxnHash as response string. So how to get that uint256 value returned by contract function ? Please Help !!

What value are you looking for (and which contract/chain)?

You may not be able to get the value directly after making a transaction. If the contract function emits an event, you can get the data from that, or call another read only function to get the data.

ERC20 contract on Cronos chain

Just for an example, not real case :

function add() public view returns (uint) {
uint num1 = 10;
uint num2 = 16;
uint sum = num1+num2;
return sum;
}

How to get value of sum from Unity ?

Or again an example :

function ownerBalance() public view returns (uint256){
return (balanceOf(owner));
}

How to get the returned value here ?
Do I need to emit event ?