Skip to main content

Unity

Funox supports Unity WebGL builds via a Unity package.

Install

  1. Download the latest FunoxUnitySDK.unitypackage from the Developer Portal.
  2. In Unity: Assets → Import Package → Custom Package… and select the file.
  3. Copy the included WebGLTemplates/Funox folder into your Assets/WebGLTemplates/.
  4. In Player Settings → WebGL → Resolution and Presentation, select the Funox template.

Initialize

C#9 lines
1using CrazyGames;  // namespace name: Funox (legacy: CrazyGames in pre-release builds)2 3void Start()4{5    FunoxSDK.Init(() =>6    {7        Debug.Log("Funox SDK initialized");8    });9}

Check status:

C#2 lines
1if (FunoxSDK.IsInitialized) { /* safe to call SDK methods */ }2if (FunoxSDK.IsAvailable)   { /* SDK is loaded in this build */ }

Lifecycle signals

C#5 lines
1FunoxSDK.Game.GameplayStart();2FunoxSDK.Game.GameplayStop();3FunoxSDK.Game.LoadingStart();4FunoxSDK.Game.LoadingStop();5FunoxSDK.Game.Happytime();

Video ads

C#6 lines
1FunoxSDK.Ad.RequestAd(2    AdType.Midgame,3    onStarted:  () => AudioListener.pause = true,4    onFinished: () => AudioListener.pause = false,5    onError:    (err) => AudioListener.pause = false6);

Rewarded:

C#6 lines
1FunoxSDK.Ad.RequestAd(2    AdType.Rewarded,3    onStarted:  () => AudioListener.pause = true,4    onFinished: () => { AudioListener.pause = false; GrantReward(); },5    onError:    (err) => AudioListener.pause = false6);

User accounts

C#8 lines
1var user = await FunoxSDK.User.GetUserAsync();2if (user == null)3{4    user = await FunoxSDK.User.ShowAuthPromptAsync();5}6 7string token = await FunoxSDK.User.GetUserTokenAsync();8// Send token to your backend for verification

Save data (typed)

C#6 lines
1FunoxSDK.Data.SetInt("highScore", 12450);2int score = FunoxSDK.Data.GetInt("highScore", 0);3 4FunoxSDK.Data.SetString("inventory", JsonUtility.ToJson(inv));5FunoxSDK.Data.DeleteKey("highScore");6FunoxSDK.Data.DeleteAll();

In-game purchases

C#1 line
1string xsollaToken = await FunoxSDK.IAP.GetXsollaUserTokenAsync();

Pass the token to a Unity-compatible Xsolla SDK or call the REST API via UnityWebRequest.

Build settings

SettingValue
Compression FormatBrotli
Code OptimizationSize
Strip Engine CodeOn
Enable ExceptionsNone in release
Memory SizeStart at 256 MB, raise only if needed
iOS is hard

Unity WebGL games are disabled on iOS by default because of memory crashes. Once your game proves stable on desktop and Android, it gets enabled. Keep peak memory low.

Optimization checklist

  • Compress textures to ASTC/ETC
  • Use Resources sparingly — prefer Addressables
  • Strip unused shaders
  • Disable physics layers you don't need
  • Enable IL2CPP code stripping