Quickstart: Unity
Use the GOOF package for Unity, build with the Goof WebGL template, and upload a zip of the build folder.
1. Add the package
Copy the folder sdk/unity from the GOOF SDK into your project's Assets folder. It holds GoofSDK.cs and the Goof WebGL template. The template already loads https://developer.goof.gg/sdk/v1/goof.js.
2. Pick the template
- Open File > Build Settings and switch the platform to WebGL.
- In Player Settings > Resolution and Presentation, pick the Goof WebGL template.
3. Start the SDK
using Goof;
using UnityEngine;
public class Boot : MonoBehaviour
{
void Start()
{
GoofSDK.Init();
}
}
4. A rewarded ad
public void OnReviveButton()
{
GoofSDK.ShowRewarded("au_0123456789ab",
onRewarded: () => RevivePlayer(),
onError: err => ShowGameOver());
}
Call it only from a button the player pressed, and grant the reward only in onRewarded. See Ads for the rules.
5. A purchase
public void OnBuyCoins()
{
GoofSDK.RequestPayment("coins_500",
onOrder: order => GrantCoins(order),
onError: err => Debug.Log("payment failed: " + err));
}
For consumable products, follow the flow in In-app purchases.
6. Pause around ads
The host fires hide before every ad or payment sheet and show after it. Mute audio and pause time there. The WebGL context and your game state are kept during an ad.
7. Build and upload
- Build for WebGL into a folder.
- Zip the build folder. The zip must hold
index.htmlat the root, or inside one single top folder. - Upload it in your dashboard. Limits are in Publishing.
Use Gzip or Brotli compression with decompression fallback on, or no compression, so the build loads from any static host.