Skip to content

thirdweb-dev/unity

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Thirdweb Unity SDK

Unity Documentation .NET Documentation

Note: Active Development

This project is currently under active development. Features, APIs, and behavior may change frequently.

Technical Demo

Experience our multichain game demo leveraging In-App and Smart Wallets for seamless gameplay, built in just three weeks - Web3 Warriors.

image

Supported Platforms & Wallets

Build games for WebGL, Desktop, and Mobile using 1000+ supported chains, with various login options!

Wallet Provider WebGL Desktop Mobile
In-App Wallet (Email, Phone, Socials) ✔️ ✔️ ✔️
Private Key Wallet (Guest Mode) ✔️ ✔️ ✔️
Wallet Connect Wallet (400+ Wallets) ✔️ ✔️ ✔️
MetaMask Wallet (Browser Extension) ✔️
Smart Wallet (Account Abstraction) ✔️ ✔️ ✔️

✔️ Supported   ❌ Not Supported   — Not Applicable

Why Upgrade to v5?

Thirdweb's Unity SDK v5 leverages the robust .NET SDK for core functionality, providing a unified API and behavior across platforms.

Key Improvements:

  • Unified API: Say goodbye to the WebGL Bridge. Now, enjoy a consistent experience across WebGL, Desktop, and Mobile platforms.
  • Enhanced Composability: Use our SDK anywhere without worrying about its state. APIs are chain agnostic, enabling seamless interaction with multiple chains.
  • Native Experience: The .NET core provides a native, predictable experience, making upgrades less daunting.
  • Simplified ThirdwebManager:
    • ThirdwebManager.Instance.SDK.GetContract is now ThirdwebManager.Instance.GetContract, returning ThirdwebContract.
    • ThirdwebManager.Instance.SDK.Wallet.Connect is now ThirdwebManager.Instance.ConnectWallet, returning IThirdwebWallet.
    • Handles multiple wallet connections and tracks the active wallet.
    • The prefab is now much simpler and straightforward to setup.
  • Optimized Package: Cleaner, lighter Unity package with minimal dependencies, enhancing performance. We took control of all the layers and rewrote them, further improving the experience when using thirdweb infra. No AWS SDK. Nethereum is used only for types/encoding. Newtonsoft.Json and EDM4U are included.
  • Cross-Platform Consistency: No behavioral differences between platforms. What you see in the editor is what you get in WebGL, Standalone, and Mobile runtime platforms.

Note:

To achieve full .NET core functionality for WebGL, we include WebGLThreadingPatcher, which makes async tasks blocking on the main thread. This is due to Unity's lack of support for C# multithreading in WebGL. This mainly affects InAppWallet initial creation (not session resuming).

Getting Started

  1. Download: Head over to the releases page and download the latest .unitypackage file.
  2. Explore: Try out Scene_Playground to explore functionality and get onboarded.
  3. Learn: Explore the .NET SDK Documentation to find full API references.

Notes:

  • Tested on Unity 2021 and 2022 LTS. Highly recommend using 2022 LTS.
  • Example scenes are built with Unity 2022 LTS; they may look off in earlier versions.
  • Newtonsoft DLL included; deselect if already installed to avoid conflicts.
  • If using .NET Framework and encountering HttpUtility errors, create csc.rsp with -r:System.Web.dll under Assets.
  • Use version control and test removing duplicate DLLs if conflicts arise.

Build Instructions

General

  • Build Settings: Use Smaller (faster) Builds (IL2CPP Code Generation in Unity 2022).
  • Player Settings: Use IL2CPP over Mono.
  • Stripping Level: Set Managed Stripping Level to Minimal (Player Settings > Other Settings > Optimization).

WebGL

  • Compression Format: Set to Disabled (Player Settings > Publishing Settings) for final builds.
  • Testing In-App Wallets (Social Login): Host the build or run it locally with Cross-Origin-Opener-Policy set to same-origin-allow-popups.

Example setup for testing In-App Wallet (Social Login) locally:

// YourWebGLOutputFolder/server.js
const express = require('express');
const app = express();
const port = 8000;

app.use((req, res, next) => {
  res.header('Cross-Origin-Opener-Policy', 'same-origin-allow-popups');
  next();
});

app.use(express.static('.'));
app.listen(port, () => console.log(`Server running on http://localhost:${port}`));

// run it with `node server.js`

No action needed for hosted builds.

Mobile

  • EDM4U: Comes with the package, resolves dependencies at runtime. Use Force Resolve from Assets > External Dependency Manager > Android Resolver.
  • Custom Schemes: Set custom schemes matching your bundle ID in Plugins/AndroidManifest.xml or equivalent for InAppWallet OAuth.

Need Help?

For any questions or support, visit our Support Portal.

Thank you for trying out the Thirdweb Unity SDK!