UnityAds Playable Guide
UnityAds Playable Guide
Check the picture below. There is the index.html file, but there is also a game.js file and
two folders of which one contains images.
So, if the device now downloads only the index.html file, it will be missing all the other
stuff.
In the screenshot below, you can see that there are multiple files and folders. Also, the in-
dex.html file is only 3 KB in size, so all the actual data is contained somewhere else (here
the main part is in “resource”).
The single index.html file MUST be inlined and SHOULD be minified
In the “BAD” screenshots from above the index.html file contains links to the other files
and folders, meaning that when the device has only downloaded the index.html file and
starts showing the playable, it actually needs to download some more stuff from those
links, so the ad is not really fully cached to the device.
Inlining is basically, a super long string of gibberish characters. It’s not gibberish to the
browser in our ad unit though of course. This data is interpreted as the type of file you are
saying it is - so as an image (or in this case actually a gif).
The same thing can be done with sound or video files. It is a rare practice, because for the
normal usage of an html file (for a website for example), this is often unnecessary. If you
simply want to update an image, you would need to change the source code of the web-
site every time. However, for caching the entire ad to the device memory beforehand, it
has to be done this way.
Minifying is a way of reducing the size of software code. It removes empty spaces and
shortens variable names etc. It is still perfectly well readable for a machine, but nearly
impossible to decipher for a human.
Additional notes:
Art assets:
Use spritemaps to contain the art assets. These are sprite maps/sheets/databases:
It can be used to show the movements of a character, essentially it can be used to ani-
mate objects.
A sprite sheet is a bitmap image file that contains several smaller graphics in a tiled grid
arrangement. By compiling several graphics into a single file, you enable Animate and oth-
er applications to use the graphics while only needing to load a single file.
Check the setting for CORS headers on the server where the file is hosted:
allow origin or Access-Control-Allow-Origin needs to be set to *
break;
case “iOS”:mraid.open(“https://itunes.apple.com/us/yourgame?mt=8”);
Please note that user agent on newer versions of iPadOS is ‘Macintosh’. We recommend
using the following logic to detect the platform a playable is running on: /android/i.test(us-
erAgent).
Filesize limitation:
Final filesize of the ad should be under 5 Mb.
Audio:
If your playable is using sound, it must use Web Audio API by default and fallback to
HTMLAudioElement or HTML DOM Audio Object. Most modern game frameworks and
sound libraries (Howler.js) are working this way. Make sure you do too.
Web Audio API is currently the only solution that respects the state of the mute/ringer
switch on iOS. Also, use `viewableChangeHandler` to mute or play sound if the app goes
background on Android.
Video Elements:
For embedded video elements inside the playables, it works as long as the video is inlined
and base64 encoded. Also make sure that the native video controls are not available.
video::-webkit-media-controls {
display: none !important; }
TECHNICAL REQUIREMENTS
BOOTSTRAPPING:
// Wait for the SDK to become ready
if (mraid.getState() === ‘loading’) {
mraid.addEventListener(‘ready’, onSdkReady);
} else {
onSdkReady();
}
function viewableChangeHandler(viewable) {
// start/pause/resume gameplay, stop/play sounds
if(viewable) {
showMyAd();
} else {
// pause
}
}
function onSdkReady() {
mraid.addEventListener(‘viewableChange’, viewableChangeHandler);
// Wait for the ad to become viewable for the first time
if (mraid.isViewable()) {
showMyAd();
}
}
function showMyAd() {
...
}
if (/android/i.test(userAgent)) {
url = android;
}
mraid.open(url);
Note: Do not use automatic redirection to the app store. The playable is not allowed to
open the app store automatically or from the very first touch within the playable.
UNITYADS PLAYABLE AD REQUIREMENTS
MRAID: Mobile Rich Media Ad Interface Definitions
Mraid is injected by our webview and you can just use the mraid methods.
Unity Ads is supporting MRAID v2.0 with the following exceptions:
Support only for full-screen interstitial ads, expand() and resize() will not be available
Custom close buttons will not be available
No support for: sms, tel, calendar and storePicture
inlineVideonext is supported from SDK 2.0.7 onwards
eg. https://myserver.com/testgame.html
Note that just https://myserver.com would not be enough without a direct url ending
with .html
Check the setting for CORS headers on the server where the file is hosted:
allow origin or Access-Control-Allow-Origin needs to be set to *
FIXED ELEMENTS
These come pre-built from Unity
Do not place any functionality to these areas
Countdown timer in the top right corner
Timer turns into a close button when ad is closeable
In the EU region, GDPR banner on the bottom
The banner is visible for the first time an ad is shown
The banner takes about 100 pixels in height
Only the privacy icon will be shown on the bottom left corner if:
- Not in the EU region
- Consent given for personalized ads
- GDPR banner was seen by the user once
START SCREEN
A short guide for the gameplay
· Gameplay should start immediately to catch attention
· Fade or animate into gameplay if no input is given
· Show initial interaction by examples
· Show more, tell less
GAMEPLAY
· Allow the player to finish the game
· Create a Download button to fit the game
A midgame download button guarantees more clicks and installs as it can be hard to judge
when the player reaches the end of the game before the ad can be closed.
You can fill the excess space with a wallpaper or move the
Download button there for example.
END SCREEN
Either fail message or congratulations
· Include the game name icon and logo etc.
· Animate the download button to give it more attention,
but do not use a strobe effect. Apple does not allow it on
their platform.
You can find the test app in th Apple Appstore and Google Play storefronts.
https://play.google.com/store/apps/details?id=com.unity3d.auicreativetestapp
https://apps.apple.com/us/app/ad-testing/id1463016906
Usage:
Upload and host the playable .html file where it can be accessed with an URL.
Or alternatively upload it to the Unity Acquire Dashboard.
If uploading to your own hosted location, please then use any QR code generator
(e.g. http://www.qr-code-generator.com) to generate a code from the URL of the playable.
Unity Acquire Dashboard generates the QR codes automatically and can be found under
your Creative Packs and clicking on “Show QR Code“
You can then use the Test App to read the URL and view the ad.
Make sure that the playable is all inlined into one HTML file and is under 5 Megabytes.
The UnityAds SDK supports iOS 9+ and Android 4.4.1+ for playables
When testing, make sure, the URL you are hosting the playable in is using httpS not only
http. iOS requires https due to the platform holders security concerns.
Check the setting for CORS headers on the server where the file is hosted:
allow origin or Access-Control-Allow-Origin needs to be set to *
You can read more about CORS here:
https://docs.aws.amazon.com/AmazonS3/latest/dev/cors.html
Some of the playables won’t work in a browser, try it with the Unity Test App and on
several different devices if possible, from old Androids to the latest iPhone.
Some of the playables will work in a browser but fail to implement MRAID correctly and
thus fail in our ad unit. In that case it is hard for you to spot that and we can check it in the
final QA. When you use our testing apps, you can spot many issues beforehand.
Install button should lead to the correct store and game. Check on an actual iOS device as
the simulator runtime doesn’t have an App Store.
Duration (check how long does it take to reach the end screen and Call-to-action). Total
experience should take just under 30 seconds.
Orientation Changes, making sure game still functions and looks okay when orientation is
switched from portrait to landscape and vice versa.
Sound Issues:
If a user locks the screen, the sound should stop. And if the screen is unlocked, the sound
should restart. Check that the physical mute button is respected.
I’m getting an error while uploading my playable:
Q: I’m getting an error “invalid URL” when I’m uploading a playable to the Dashboard
A: We have some requirements for using the upload via URL functionality:
Playable must be hosted on a HTTPS server, not HTTP server.
The URL must contain the full filename, including the .htm / .html extension.
The URL can not have parameters after the filename and extension.
The URL must be a valid web address, not a local URL.
Q: I’m getting an error about failing to fetch content when I’m uploading a playable to the
Dashboard via a URL
A: Verify that you can access the playable with the Ad Testing app and verify that your
CORS is set up properly. Please check section ‘Suggested CORS setup’ for more informa-
tion. You can also upload the playable directly from a file on your local computer.
Check the setting for CORS headers on the server where the file is hosted:
allow origin or Access-Control-Allow-Origin must to be set to *.