Skip to content

Unity SDK

Download Unity SDK

We also suggest that you read the following Unity WebGL export tips. They may help you to reduce the final build size and increase the performance of your game, thus increasing your revenue. Furthermore, you can also have a look at the WebGL Optimizer utility that the CrazySDK provides by default.

Warning

The new Unity SDK contains major changes that make it similar to our other SDKs. We recommend that you delete the folders CrazySDK and CrazyOptimizer (if present) before importing it. Don't forget to consult the docs if you encounter issues. The SDK also requires now to be manually initialized.

Introduction

The SDK is found in the CrazyGames namespace, which you will have to import at the start of your files:

using CrazyGames;

The SDK needs to be manually initialized like this:

CrazySDK.Init(() => { /** initialization finished callback */ });

Since the initialization is done asynchronously, please don't call any methods from the SDK until the callback provided to the Init was called. You can create a loading scene for example, in which the SDK is initialized.

Make sure that you also import the Plugins and WebGLTemplates when importing the SDK.

CrazyGames supports only compressed builds (either Brotli or Gzip). This means that the development builds won't run in the QA tool, since they are not compressed.

Template

The SDK contains a WebGL template that lets your game run using the same setup as it would on crazygames.com. In order to use it, make sure you have imported the template (WebGLTemplates/Crazy_5_6+ and WebGLTemplates/Crazy_2020 folders should be present in your project). Then, in your Build Settings (File/Build Settings...), in the Player Settings, under Resolution and Presentation, select Crazy_5_6+ if you are using a Unity version prior to 2020 or Crazy_2020+ for the 2020 version and after.

WebGL template

By default, the SDK is not initialized on your domain, and all the calls to the SDK will produce nothing. However, if you upload the game on your domain using the above-mentioned templates, the SDK will start in demo mode and you will be able to see demo ads/banners and console logs.

Sitelock

Sitelocking is done automatically on game start. It allows your game to run only on CrazyGames.com and our affiliated sites. This ensures that your game cannot be stolen and hosted on other domains, so you do not lose any revenue.

By default, the sitelock will also block the game on your domain. To avoid this, you should add your domain to the list of whitelisted domains in the CrazySDK settings. You can find the settings in CrazySDK/Resources/CrazyGamesSettings.

Info

When reimporting the SDK, Unity resets these settings.

Whitelist domain

QA Tool

You can check if the game is running in QA Tool like this:

CrazySDK.IsQaTool;