Unity SDK v4 to v5 Migration Guide
This guide outlines the migration process from thirdweb Unity SDK v4 to v5. SDK v5 offers enhanced features and modularity, and also allows direct integration with the .NET SDK.
- ThirdwebManager: The
ThirdwebManager
remains the recommended entry point and offers enhanced management of wallets, contracts, and the main ThirdwebClient. However, it simply acts as a wrapper for some lower level APIs from our .NET SDK and is optional. - Contract Interactions: Contract interactions are done through the
ThirdwebContract
class, which has more flexiblePrepare
,Read
andWrite
methods. This allows for easier interaction with various chains. It also has built-in extensions for common contract types like ERC721, ERC1155, etc. - Wallet Management: Wallet management has been modularized, providing more control over wallet providers simultaenously. You can instantiate wallets directly through their
Create
function or throughThirdwebManager.Instance.ConnectWallet
. - Infrastructure: An API key is required in v5 for access to thirdweb services like RPC, Storage, Account Abstraction and more. Set your client id and bundle id in your
ThirdwebManager
inspector. - Integration with .NET SDK: Unity SDK v5 allows you to directly use the .NET SDK for improved flexibility, especially in contract interaction and wallet operations.
Start by downloading the latest version of the Unity SDK from the releases page. Ensure the old SDK files are removed and the new SDK is imported into your Unity project.
In v5, the majority of state management has been moved off the ThirdwebManager
or ThirdwebSDK
, no longer tying you to a specific chain or wallet at all times. The Unity SDK acts as a wrapper for the .NET SDK, providing a more user-friendly interface.
The settings that previously crowded the ThirdwebManager
have been removed, most of these options can now be set as runtime options when connecting to a wallet or contract. This allows for more flexibility - you may instantiate as many contracts and wallets as you need, on multiple chains, and switch between them easily, or even execute multiple cross-chain transactions simultaneously.
You will find that the general structure of functions and classes are similar to v4, but the arguments and return types have been updated to be more flexible and modular.
We've recreated similar APIs to v4 in v5 to make the transition easier. Anything previously under ThirdwebManager.Instance.SDK
is now directly accessible from ThirdwebManager.Instance
or through a static class. Review the Unity v5 and .NET SDK documentation to explore the new APIs.
Contract interaction has been simplified in v5. The specific contract interfaces (e.g., ERC721, ERC1155) are now handled via ThirdwebContract
with more flexible extension methods.
In v5, wallets are more modular. You can connect to multiple wallets simultaneously and switch between them easily.
v5 requires an API key for storage and RPC services. You can generate an API key from the thirdweb dashboard and integrate it into your Unity project.
If you were using our example prefabs from v4 in production, you may need to back them up as they have been removed from v5. You can still use them as a reference to create your own prefabs in v5.
You may choose to adapt their code to v5 or recreate your own UI and use the new APIs we offer.
Generally, for a wallet connect button, all you need is to call var wallet = await ThirdwebManager.Instance.ConnectWallet
with the appropriate options.
You can then display the balance using await wallet.GetBalance
or other extension methods. Utils.GetChainMetadata
will help find native token symbols and more, dynamically.
New production ready prefabs will be available in future releases.
The .NET SDK Documentation provides a comprehensive reference for all classes and methods available in the Unity SDK v5.