🎮Connect with Unity

Once you have your Moralis Server launched it's time to connect to it via the Moralis Unity SDK. This guide will show you how you can do it in Unity with the Web3 Unity Boilerplate

Web3 Unity Boilerplate

  • The Unity Boilerplate include C# Moralis SDK and has an example Unity scene allowing you to login your users via their wallets, read their tokens and NFTs, interact with smart contracts and much more.

Adding Moralis to Your Unity Game

The SDK support Unity version 2020.3 LTS and up

Downloading the SDK

Download the latest version of the SDK here Then navigate to the releases and select the lastest version of the sdk. download it as a unity package

Creating a unity project

  • Create a new Unity project with Unity HUB, you can select any template of your choice, add a name to your project and a location.

  • When the project is created, navigate to the folder you downloaded the package, drag and drop the package into the Assets folder in unity, an importing menu will popup and then click import to import the package into your project.

Configuring the project

  • In your unity project, open MoralisWeb3ApiSdk->Example folder and double-click on the DemoScene to lauch it in the scene view.

  • In the "Hierachy" panel under DemoScene click on the "MoralisSetup" gameobject, if the attached script sub-section is not expanded, expand it, also do the same with the "WalletConnect" gameobject, take a look at this script and explore their code and the varibales they links with.

  • Using the information from your Moralis Server, fill in Application Id, and Server URL on the "MoralisController" script attached to the "MoralisSetup".

For WEBGL

  • In Player Settings change the WebGL template to the Moralis WebGL Template.

Running the application

  • Run the application by clicking the Play icon located at the top, center of the Unity.

  • Click on the "Authenticate" button to authenticate to Moralis using your Wallet.

  • Explore the demoscene.

Webgl can only be tested on build

See all User Assets in the Moralis Database

As soon as the user logs in Moralis fetches all the on-chain data about that user from all chains and puts it into the Moralis Database. To see the Moralis Database go your server settings into the Database tab.

You will see the database of that server once you click Access Database. Moralis fetches data from all blockchain where the address of the user has been active and you can see and query all tokens, NFTs and past transactions of the user all in one database.

Tutorial guides

These example videos/tutorials were made with the sdk version < 1.2.0, some of the code may not work for version >= 1.2.0, take a look at the changelog and download migration video

Guides on how to use the moralis unity sdk in unity on various platform.

Last updated