Adverty

Documentation

    New and improved Adverty Unity SDK

    Improvements in SDK 5

    • Increased Flexibility: Now supports custom ad sizes, providing more customisation options.
    • Enhanced Mobile Experience: All clicks open directly in the app on mobile devices. 
    • ● Optimized Performance: SDK 5 is nearly half the compiled size of SDK 4.
    • New Payment Callback: Added a payment callback feature, allowing publishers to track estimated revenue through their preferred analytics provider.

    To get started with SDK 5, refer to the Quickstart Guide or the Upgrade Guide. You can download SDK in the publisher portal under “Resources” to get an account you simply signup at top right on this site:

    Change log

    Change log for SDK 5 can be found here

    Overiew

    SDK is built with a base binary that is non-dependent to game engine and can be used in other engines. Currently Adverty do offer enginee plugins for Unity and Cocos2dx (closed beta). To get access to closed beta or support to add the core binaries to your custom enginee feel free to reach out to client-team@adverty.com In the reminder of this documentation we will focus on the Unity Plugin.

    Plugin distribution

    Adverty Unity plugin is distributed as a .unitypackage. The package includes a few different folders:

    • Example: Folder which includes examples of how to use the SDK including a complete scene showcasing how adverty Adplacements can be used. This folder is recomended to be imported but when integration is complete you can remove it but remeber to move out files that you might use from the examples.
    • Materials: Folder includes a single material called AdMaterial which is used
    • ● Plugins: Includes all binaries of the underlaying common SDK compiled for different platforms and architectures. To run SDK in editor Darwin/Windows binaries are needed.
    • Scripts: All C# scripts needed to integrate the SDK. Below are the subfolders listed.
      • Legacy: Scripts to help update from SDK4 to SDK 5. Can be deleted after they have been used
      • Library: Common scripts which are used to integrate Adverty SDK. Each file includes comments on how they should be used. For majority of files we suggest that you inherit from the class and place the new script in a new folder to keep your integration files separated from the main Adverty files (Will ease future updates of the sdk). All files includes a summary in top of file which explains if and how you are recomended to change the file content.
      • URPSupport:Both builtin and URP renderpipelines are supported out of the box here we have URP specific files

    Requirements

    • ● Android API 24 (Android 7)
    • ● iOS 12.0
    • ● OSX 12.0
    • ● Windows 10

    Our standard implementations of UIAdplacement is using Unity UI package (availible in UnityPackageManager). If your using other UI system feel free to edit UIAdplacement.cs

    Setup SDK

    In this section we will describe in deepth how to set up the Adverty SDK for your app. Start by importing Adverty SDK into your project. If you are updating from SDK 4 to SDK 5 we recomend the upgrade guide.

    Import the SDK

    ● Download the unity package from Adverty to your project. If your facing issues while updating remove Adverty folder and reimport the package.

    Setup the SDK

    ■ Click the dropdown Tools > Adverty5 > Settings and add the API/s key generated in the portal for the supported operating systems. Yo do not need a specific key for editor Adverty SDK will use one of the supplied for mobile platforms. For testing integration you should use the Sandbox mode which is enabled with a checkbox.

    ■ To Start Adverty SDK you need to add the AdvertyLoader to any active GameObject on the scene. This scripts starts the SDK and do add AdvertyLooper to the main camera of the scene. If your using another camera as main game camera you should create your own version of AdvertyLoader which overrides the AddLooper and AddViewabilityCheck methods to add corresponding scripts to your main GameCamera.

    ■ NOTE: To start earning revenue, remember to publish your application in the portal at adverty.com to set the application to “Live”. Apps which is not set to live status will fail to sign-in to our service without sandbox enabled.

    Activate AdvertySDK

    ■ The AdvertyLoader class includes a method called StartAdverty where Adverty.Start(launchData). Where the launchData includes the api-key, sandbox setting and userdata. By default api-key and sandbox setting is grabbed from the AdvertySettingsAsset but can be supplied directly in code

    Setup Ad placements

    ● Add an ad placement to your scene

    ○ Locate an AdPrefab in Example/Prefab folder and add it to your scene. The prefabs are of ratios of common adsizes. However you are free to finetune the width and height of the placement as you do with a regular unity object.

    ○ There are 3 different renderers supported out of the box: MeshAdPlacement, SpriteAdPlacement and UIAdplacement.

    ○ By default they are using the AdMaterial.mat however you are free to use a material of your own choice. Only thing to keep in mind is that Adverty SDK does set the mainTexture of the material. If your using any other texture name on material you need to create a new AdPlacment script which inherits from either AdPlacment or the specific AdPlacment and overrides the ApplyPlacementTexture method.

    Test your ad placments

    ○ Th most basic test of an adplacment is to run your game with Sandboxmode enabled. If everything is setup correctly you will see a yellow ad with the text “Your Ad Here”.

    ○ To make sure that your units is considered viewable you can use the sessiowide callback OnAdViewed. For an example of how you can use it look at Example/Scripts/AdvertyLoaderWithCallbacks.cs

    General advices

    Adverty requires internet to load ads during runtime and there is always a possibility an ad is not delivered. To give the user an as enjoyable experience as possible we suggest the following actions.

    Apply your own texture

    You can apply your own texture to a adplacment. This makes it so that if the AdPlacment is not receiving an ad your desired texture will be shown. If an ad is delivered your texture will be replaced by the ad. You do this by simply adding the texture to the material of the AdPlacment, as you do on a regular gameobject in Unity

    Disable MeshRenderer

    In previous version you could disable the MeshRenderer to simply not show the adplacement if it wasn’t filled by Adverty. This is not something we support out of the boc but it can be achieved by listening to OnAdPlacementActivated callback and in that case enable the meshrenderer.

    using System.Collections;
            using System.Collections.Generic;
            using UnityEngine;
            using Adverty5.AdPlacements;
            
            public class DisabledMeshRenderer : MonoBehaviour
            {
                private AdPlacement targetPlacement;
            
                protected void Start()
                {
                    targetPlacement = GetComponent();
            
                    targetPlacement.AdPlacementActivatedEvent += OnAdPlacementActivated;
                }
            
                private void OnAdPlacementActivated(AdPlacement placement)
                {
                    targetPlacement.GetComponent().enabled = true;
                }
            
            }

    Scripting API

    Adverty

    void AdvertySDK.Start(LaunchData launcdata)

    To start the AdvertySDK you need to call Adverty.Start(LauncData launcdata).

    Example with only required parameters:

    public class ActivateAdvertyExampleClass : MonoBehaviour
                protected virtual void StartAdverty()
                {
                    UserData userData = new UserData() { consented = true };
                    LaunchData launchData = new LaunchData { apiKey = AdvertySettings.APIKey,
                                                             sandboxMode = AdvertySettings.SandboxMode, userData = userData };
                    Adverty.Start(launchData);
                }
            

    Observe that above example sets userData.consented = true. This should be set false if user hasn’t consented to share personal data.

    UserData struct

    In Scripts/Library/API/APIConfig.cs is the UserData struct defined and also a constructor for creation of instances. We recomend to always use the constructor to avoid potential memory leaks as pointers to this created object is shared with native code at start of SDK. Not allocating memory for all fields leads to undefined behaviour.

    public struct UserData
                {
                    public Gender gender;
                    public int yearOfBirth;
                    public bool COPPA;
                    public string consentString;
                    public string gppConsentString;
                    public int gppSid;
                    public bool consented;
            
                    public UserData(Gender gender = Gender.Unknown, int yearOfBirth = -1, bool COPPA = false, bool consented = true,
                                    string consentString = "", string gppConsentString = "", int gppSid = 0)
                    {
                        this.gender = gender;
                        this.yearOfBirth = yearOfBirth;
                        this.COPPA = COPPA;
                        this.consentString = consentString;
                        this.gppConsentString = gppConsentString;
                        this.gppSid = gppSid;
                        this.consented = consented;
                    }
                }
           

    void Adverty.Stop()

    Terminates the current Adverty session, if any exists.

    AdvertyCallbacks

    Adverty are supplying many callbacks to publishers and all are shown by example in the scripts AdvertyLoaderWithCallbacks and AdReceivingValidation.

    • iab
    • iab
    • Tag
    • IAB Europe