Ethereum Unity3D Boilerplate Questions

This is a thread to discuss the Ethereum Unity3D Boilerplate (https://github.com/ethereum-boilerplate/ethereum-unity-boilerplate). This boilerplate is very popular and itā€™s important that you fully understand how to use it in your projects.

We are here to help! If you have any questions about how to use it or how to set it up you can ask here!

4 Likes

Hi! Really excited about this Unity integration! I was looking through github and am looking forward to doing a deepdive. I have a quick question in regards to authentication. I saw that in ios/android you get a wallet select list, while for the rest platforms it is a qr code. I am looking create a Unity WebGL project - for this, is there any way to directly connect to Metamask browser extension, without a QR code. Is it possible to do this directly from unity? Or would I need to somehow integrate Moralis JS to make it work?

Thank you!

2 Likes

very nice to see this, but the link for the required installs donā€™t seem to be complete. where do I find the Moralis/unity package ?

2 Likes

@m33lucky,

If you go to https://github.com/ethereum-boilerplate/ethereum-unity-boilerplate. It is under ā€œReleasesā€ on the right hand side of the page.

The direct link is https://github.com/ethereum-boilerplate/ethereum-unity-boilerplate/releases/tag/v1.0.0.

Regards,

David.

3 Likes

@gsanlob,

Unfortunately there are two issues with WebGL in Unity3D when using the Moralis SDK. Currently WebGL does not support multi-threading or web-sockets consistantly, both of which are a big part of the Moralis SDK / Web3API. This issue is well known in the Unity Community and is due to how WebGL works. We are working on a fix to this and hope to have it WebGL working in a few days.

I am hoping that with the solution we are working on, a WebGL application will not need to use a QR code.

Regards,

David

2 Likes

Hi David,

Thank you for explaining and for working on a solution to this. Yea, the WebGL lack of multi-threading has been a pain on my end as well. I hope something could be worked out, cause it would be amazing to have the power of Moralis! Iā€™ll keep my fingers crossed and keep checking back.

Thank you!
Gleb

1 Like

@gsanlob,

Have you tackled this issue before? The route I am taking is to use UniTask. So far I have had some success with this library and I know it has been useful for other projects seeking to overcome the threading issues in WASM / WebGL.

Thank you,

David

Hi David,

Unfortunately I donā€™t have experience with UniTask. The pain I was referring to was regarding Unity sound in WebGL, since itā€™s not multi-threaded there were a host of problems, especially with microphones. UniTask looks very interesting, Iā€™ll definitely look into it as well.

Thanks!
Gleb

1 Like

If i can not use WebGl with the moralis SDK can you give me some guidance on how to connect my game with the user? so that he can play my game? I want to build an NFT game

1 Like

Hi guys,

This is certainly exciting news and I canā€™t wait to test it out.

I have tried to get the demo working by completing the following:

  1. Download UnitySDK
  2. Change VS preferences within Unity
  3. Import SDK to Unity engine
  4. Load up the Demo scene
  5. Insert my unity URI and APP ID

However, if I press the play button in Unity I get the following error:
ā€œNon-Convex MeshCollider with non-kinematic Rigidbody is no longer supported since Unity 5. If you want to use a non-convex mesh either make the Rigidbody kinematic or remove the Rigidbody component.ā€

Now, I donā€™t think this should actually be a problem with authentication, however, I try to press the authenticate button (or any other button) in the game scene from the unity engine and I get no interaction at all. So I canā€™t proceed with the authentication process.

So my questions are:

  1. Do I have to build and run the demo scene before I try this or should it be working direct from the unity engine.
  2. When I do finally get this to authenticate, is this simply using the QR code from my phone to scan or do I need a particular app installed on my phone (sorry use to it opening up metamask, but as stated above, it has limitations).
1 Like

Hi @icefire900,
I am facing the same issue but I am able to run the demo by unchecking the Mesh Collider at ā€œChest_upā€ file.

Hope this helps!

1 Like

@Alice1989,

Currently the Desktop, iOS and Android builds (XBox if you have a dev license from Microsoft) are working.

I am working on an update to make the SDK compatible with WebGL and hope to have it done in the next couple of weeks. In the meanwhile you can develope your game and run it in the IDE (or as a desktop, iOs and Android) app.

Regards,

David

@icefire900,

I apologize for this it was an oversight on my part. I have posted a fix to GitHub. Additionally the updated package I posted this morning contains this and some other minor fixes.

Additionally the fix that @peh1696 mentioned will fix this particular issue.

Regards,

David

@peh1696,

Thanks for responding, it is appreciated. This issue is now fixed in Github as well.

If you notice anything else please let me know!

Regards,

David

1 Like

Hi, Iā€™ve just imported ethereum-unity-boilerplate, but I am missing reference for HttpUtility.UrlEncode, is there some libraries I have missing?

Regards,
Daniel

1 Like

Daniel,

That is a bit confusing. There is only one reference to HttpUtility.UrlEncode in the project and that is in Moralis.Web3Api.Client.ApiClient. HttpUtility is a class in System.Web so it should always be avaialble.

Can you provide a screen shot of the error and the version of Unity3D you are using, and what platform your project is set to use in Build Settings?

Thank you,

David

I found the problem, unity doesnā€™t automatically include System.Web assembly. So Iā€™ve added csc.rps file to assets with -r:System.Web.dll. And it fixed my problem.

Thanks for your quick response
Daniel

1 Like

Cool, thank you for letting me know you found an answer!

Hey there, I downloaded the project and have all the server deployed in the moralis , yet with using the trust wallet with Wallet Connect , still canā€™t validate the URI . Is there any alternative to it ? Also can is there way to do multiplayer operation in Moralis or do I need to get another multinetworking server for it ? Thanks

1 Like

Hi David, nice work with the unity 3d boilerplate!
I have a few pieces of feedback:

  • The demo is very nice, but it would be good if you could delete the ā€œexampleā€ folder when importing into a project and that folder didnā€™t contain any of the dependencies (right now it contains a bunch of dependencies for wallet connect).
  • It would also be good if there were more examples of using the API to query and fetch Moralis objects
  • In some places you put editor scripts in EditorTools folder instead of special named Editor folder - not sure why?
  • Looking forward to the WebGL implementation and improvements to WalletConnect!

I also have a suggestion of a web3 feature that would be really cool: Unity has addressables - resource bundles that can be created at build time and downloaded like DLC - it would be really cool if we could build them and push them up to IPFS in the editor, and then pull them down from IPFS at runtime. I think that would open up a lot of cool possibilities!

1 Like