This repository has been archived by the owner on Nov 12, 2022. It is now read-only.
Releases: thirdweb-dev/unity-webgl-sdk
Releases · thirdweb-dev/unity-webgl-sdk
v1.0.0
Installation
In the Unity project:
- Download the unitypackage below
- In your Project, Right click -> Import Package -> Custom Package. Select the unitypackage that you downloaded from (1).
- Include the
Thirdweb
prefab in your scene. https://github.com/nftlabs/unity-webgl/tree/master/Assets/Thirdweb - Access the Thirdweb SDK however you want! An example use case of the SDK: https://github.com/nftlabs/unity-webgl/blob/master/Assets/Examples/MouseClickTest.cs
In the web project:
npm install @3rdweb/sdk @3rdweb/unity-bridge
- In your web app, initialize ThirdwebBridgeSDK: https://github.com/nftlabs/unity-webgl-template/blob/master/src/App.tsx#L11
// replace RPC url to the correct network RPC url
const bridge = new ThirdwebBridgeSDK("https://rpc-mumbai.maticvigil.com")
- Create UnityInstance in the window context for message bridging: https://github.com/nftlabs/unity-webgl-template/blob/master/src/App.tsx#L20-L30
const interval = setInterval(() => {
if (window.createUnityInstance) {
clearInterval(interval);
window.createUnityInstance(canvasRef.current, window.unityConfig)
.then((unityInstance) => {
window.unityInstance = unityInstance;
});
}
}, 500);
- After connecting wallet, update the ThirdwebBridgeSDK signer whenever a signer is available: https://github.com/nftlabs/unity-webgl-template/blob/master/src/App.tsx#L45-L50
const signer = provider.getSigner();
bridge.setProviderOrSigner(signer);
- Your C# Unity SDK can now make authenticated SDK function calls like transferring asset or buying asset.