Ethereum Unity3D Boilerplate Questions

@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

Check out this page in the unity docs it might explain what is going on (with .Net Standard 2.0 vs .Net 4.7)

1 Like

The packages folder does contain some W.C. specific components. I can move this out of the example folder. The only other specific W.C. item is the WalletConnect object but this is an empty game object I created and dropped the W.C. script into.

Agreed. I am not sure if I will add these to this boilerplate or create a demo project just for that purpose. I have some rough examples I used for integration testing. May polish those up and post them, but they are not ā€œgameā€ like.

Hmmā€¦

I guess I need to fix that :slight_smile:

Me too - it is a big hill to climb. Initial try looked good, working through the update now.

I think you are refering to the project files but am not sure.

The project files themselves are auto-generated and anytime I manually update them they are re-generated. If you know of a way to have the project file generate with a TargetFrameWorkVersion other than the default please let me know. To date I have not found on online.

I did develop the SDK and API in .Net Standard2.0 and in the User Preferences this is what I set API Compatibility Level to (this is the prescribed method in the article you linked to as well).

Please continue to share any and all hints and tricks - they are helpful, and I am always learning.

Thanks,

David

You can use Moralis to create a multi-player game. Ivan did a demo to show the basics sample code. Note this demo is not Unity but the same concept can be created using the current Moralis / Unity3D SDK.

As to the Wallet issue:

  1. When you run the game do you see a QR Code?
  2. When you scan the QR Code with Trust Wallet (Settings -> WalletConnect) is a message of any type displayed?

Can you use other Wallets - yes, you can use any wallet that is compatible with Wallet Connect (though MetaMask wallet does not always respond to Wallet Connect requests).

Regards,

David