Installing PnP Unity SDK
Download the Unity Package
Download .unitypackage from our latest release and import the package file into your existing Unity3D project.
You may encounter errors when importing this package into your existing project.
The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)
To fix this problem you need to add the following line into the dependencies object which is inside
the Packages/manifest.json
file.
"com.unity.nuget.newtonsoft-json": "3.2.1"
We recommend you use the Nethereum Library for making the blockchain calls. You can check our documentation on how to integrate Nethereum it with Web3Auth here.
Configuration
Configure a Plug n Play project
-
Go to Developer Dashboard, create or select an Web3Auth project:
-
Add
{{SCHEMA}}://{YOUR_APP_PACKAGE_NAME}/auth
to Whitelist URLs. -
Copy the
Client ID
for usage later.
Configure Deep Link (for Mobile Devices)
Unity SDK works on Unity deep linking features to redirect the callback from Web3Auth. Before building the application for Android/IOS you need to register the redirect_uri, which can be easily done using the tool provided inside the SDK. To achieve that, you need to follow the steps mentioned below.
-
Open the "Deep Link Generator" tool provided by Web3Auth Unity SDK from
Window > Web3Auth > Deep Link Generator
-
Enter the
redirect_url
{{SCHEMA}}://{YOUR_APP_PACKAGE_NAME}/auth
and click generate.
We're using torusapp://com.torus.Web3AuthUnity/auth
as the redirect_url
in our example just to
give you a reference on how your app's redirect_url
should look like.
Add Web3auth Configuration Script to the scene
-
Inside
Project > Assets > Plugins > Web3AuthSDK
there is a file calledWeb3auth
that must be dragged to the component in the scene. In our examples we are using a canvas. So you can now configure you clientId, rediretUrl and Network from the UI.
Android
- You can create an android manifest in unity