Skip to main content

Getting started

The Unity bridge allows developers to utilize Tweed's SDK in a WebGL compiled Unity game. With the Unity bridge developers can embedd all the blockchain and web3 functionalities found in Tweed's SDK. With a simple integration process players can:

  • Own an in-game crypto wallet
  • Send and recieve tokens and NFTs
  • Buy NFTs using their payment card
  • View their transactions
  • Play in a multichain environment (EVM and non EVM)
  • Interact with smart contracts
  • And much more...

This is how it works:

`Unity flow`

The integration with the SDK doesn't change, a JS backend SDK and a JS frontend SDK will be integrated into the platform, in addition there are 3 files that needs to get integrated as well, these 3 files are the Unity bridge:

  1. TweedSDK.cs - Handles the calls to the SDK functions from the Unity MonoBehaviour object
  2. TweedSDK.jslib - Handles the communication from the Unity app to Tweed's frontend SDK
  3. TweedSDK.js - Handles the communication from Tweed's frontend SDK to the Unity app

The Unity-JS bridge can be downloaded from our Unity bridge Github repo
A fully functional example can be cloned from our Unity bridge example repo

Installing the bridge

The bridge should get incorporated into the Unity app to allow in game blockchain functionality.

  • TweedSDK.cs --> <UnityProjectPath>/Assets/
  • TweedSDK.jslib --> <UnityProjectPath>/Assets/plugins
  • TweedSDK.js --> <FrontendProjectPath>

The first two files will get baked into the WebGL compiled app using the Unity compiler. Compiling the Unity app will be done using: File --> Build Settings... --> WebGL --> Build The third file will get loaded into the frontend that hosts the Unity WebGL app using something like:

<script type='module' type='text/javascript' src='/src/TweedSDK.js'></script>

Using the bridge

Use our JS documentation to learn about the SDK functionality. Every function is divided to two parts:

  • function_name - calling the SDK function
  • function_name_cb - a callback function that will have the returned data

Calling the following function:

TweedSdkImports.GetOrCreateWallet("ethereumSepolia");

Will return the wallet address in GetOrCreateWallet_cb