Gravity SDK is a tool for authorizing users who own NFT wearables and loads assets into your Unity project.
Gravity SDK WebGL example requires the GLTFUtility package to be installed. To install it
- Go to “Window / Package Manager”
- Click “+” button
- Select “Add package from git URL”
- Paste
https://github.com/siccity/gltfutility.git
and click “Add” - Click “Import”
Download gravitylayer-unitysdk-webgl-example.unitypackage from Releases. To install the package
- Go to “Assets / Import Package / Custom Package”
- Select
gravityts-unitysdk.unitypackage
- Click “Import”
There are two scenes:
- Plugins/GravityLayer/Example/Scenes/WebLogin - allows users to connect a Metamask wallet
- Plugins/GravityLayer/Example/Scenes/ExampleGravitySDK - demonstrates how a user is authorized and wearables are loaded through Gravity API
To make a build
- Go to “File / Build Settings”
- Switch Platform to WebGL
- Click “Player Settings”
- Select “Player” section
- Expand “Resolution and Presentation”
- Select Web3GL - 2020x
- Expand Publishing Setting
- Switch “Compression Format” to “Disabled” and close “Player Settings”
- Add WebLogin scene to the build (drag it from Project hierarchy window to Build Settings window)
- Add ExampleGravitySDK scene to the build.
- Click “Build” and type a new folder name for build.
In order a demo to work properly you need to run a proxy server for Gravity API. We already set it up (you will need Node.js and npm to be installed). To install the proxy server:
- Clone it from here.
- Open its folder and type:
npm i
npm run serve
After that, copy all content from the build folder you created above to the folder “webgl” (or you can delete “webgl” then copy the build folder and rename it to “webgl”).
That’s it. Type in your browser http://localhost:3000/
and it should work.
For more details see documentation.