Adverty

Documentation

    Release notes

    • ● Overall performance and memory usage improvements

    Known Issues

    In Unity 2019.2, Unity and Native graphic device is not synced from start generating an error log OPENGL NATIVE PLUG-IN ERROR: GL_INVALID_ENUM. This does not affect the functionality and will only be logged once. 

    Requirements

    • ● Officially released Unity versions 2018.4 or later.
    • ● Unity Built-in Render Pipeline
    • ● “32-bit Display Buffer” set to true, under “Resolution and Presentation” 
    • ● Compute shader compatible devices
      • Windows PC with Directx 11 or 12 graphics API and Shader Model 5.0 GPU
      • macOS and iOS using Metal graphics API
      • Modern Open GL platforms (Open GL 4.3 for windows and Open GL ES 3.1 for Android)
      • Vulkan for Android
      • Preview Linux 
      • Android 5.0 (build support from Android 4.0) together with above requirements
      • iOS 8 together with above requirements
    • ● Scripting backend .Net 4.0
    • If you are building an Android application and want to test your application in the Unity editor 2018, it is a requirement to no graphics emulation and to do that you need to check “No Emulation” in Edit -> Graphics Emulation -> No Emulation. This is required to be set each time you start Unity.

      On Mac you need to have Metal Editor activated to test your application. ProjectSettings> Other Settings > Metal Editor Support

    Scriptable Render Pipeline

    SRP support is currently in beta state, please contact publisher-support@adverty.com if you want to check out the beta package.

    ProGuard Rules

    If you are using ProGuard for Android there is a set of rules that needs to be used to maintain the AdvertySDK in the building process.

    -keep class com.unity3d.player.**{ *; }
        -keep class com.adverty.**{ *; }

    Setup SDK

    In this section we will describe in deepth how to set up the Adverty SDK for your app. If you are looking for a quick guide take a look at 7 easy steps to get started

    Import the SDK

    ● Download the unity package from Unity Assetstore or the SDK repository and import it to your project. If your facing issues while updating remove Adverty folder and reimport the package.

    Setup the SDK

    ■ Click the dropdown Tools > Adverty > Settings and select the platform for your application (AR, VR or Mobile). Then add the API key generated in the portal.
     Then call the AdvertySDK.Init with parameters to start an Adverty session.

    ■ NOTE: To start earning revenue, remember to publish your application in the portal at adverty.com to set the application to “Live”.

    Set correct MainCamera

    ■ Set the correct Main Camera through AdvertySettings.SetMainCamera(Camera camera). AdvertySDK incorporates camera and rendering calculations on the main camera. Use this method to specify the main game camera to the AdvertySDK. This is important to ensure revenue for your ad units.

    Activate AdvertySDK

    ■ To activate the AdvertySDK you need to call AdvertySDK.Init. Calling Init without any of the optional parameters will use the current configuration set on AdvertySettings and trigger an SDK sign in. If any of the data change you should call Adverty.Init again to have an Adverty session with the updated parameters. If you want more control of the data used to initialize your session you can use more parameters to the AdvertySDK.Init described further down

    Example with only required parameters:

    public class ActivateAdvertyExampleClass : MonoBehaviour
        {
            void Start()
            {
                UserData userData = new UserData(AgeSegment.Unknown, Gender.Unknown);
                Adverty.AdvertySDK.Init(userData);
    
                Adverty.AdvertySettings.SetMainCamera(YourGameCamera);
            }
        }
        

    Setup AdUnits

    ● Add an ad unit to your scene

    ○ Locate either the GameUnit.prefab or MenuUnit.prefabin Assets/adverty/Prefabs/ in the project window hierarchy.

    ○ Drag the prefab into the scene and position it as you do with any regular game objects in Unity. Menuunit needs to be placed on a Canvas

    ○ Snap the GameUnit to a surface.

    • ■ The ad unit can be attached to any surface by activating the “Snap to surface” checkbox in the top left corner of the preview window. When the ad unit is selected, click on a desired surface to attach the ad unit to it. This will adjust the position and rotation of the ad unit to match the surface.

    Surface

    ● Ad unit settings

    It is possible to add different meshes to the unit, however it has to be an Adverty generated mesh. The package includes a standard and flat UnitMesh (Adverty/Resources/Meshes). It is also possible to generate and store new meshes with different bending properties. Click on “Create Mesh” in the unit editor to access this functionality. The new mesh is bendable in one axis at the time (X-axis or Y-axis) and in either direction (concave or convex). Click the “Save mesh” button to store this mesh somewhere in the project folder. This generated mesh is reusable on any ad unit.

    Convex_x

    Convex_y

    Concave_y

    Concave_x

    ○ VR only: In the SceneContext™ section, set the properties of the ad unit according to the context of the surrounding scene. Try to be as specific as possible to optimize the ad relevance. This will maximize the eCPM and your revenue. Note that some context settings have the option to select more than one predefined value.

    VR

    Enable Adverty Debug

    ■ Go to Tools > Adverty > Debug and check “Enable Adverty Logs” to enable debug logs from the AdvertySDK for testing purposes.

    When you create a new app through the Portal the app will be set into “Sandbox”-mode. This means that you will retrieve sample campaigns in your app and inside the Unity Editor. Depending on if your unit allows interaction or not it will look like below image where the left does not allow interaction and the right does.demo

    Enable Sandbox Mode

    Enable sandbox mode by checking the checkbox at Adverty -> Settings “Sandbox Mode”. It is enabling you to enable sandbox in the editor and keeping your production key live. Sandbox setting means that you will retrieve sample campaigns in your app inside the Unity Editor and on devices. With Sandbox enabled you will not be able to earn any revenue so make sure to untick the checkbox and have your app set to live in the Portal before publishing your app.

    Test your ad units

    ○ The ImpViz™-component is a real-time impression indicator that shows when ad units placed in the scene generates impressions. This helps you optimize the monetization potential of each ad unit. Remember to remove the ImpViz-component before publishing you application.

    ○ Locate the impVizComponent in the Adverty.dll plugin and attach it to the adUnit gameObject that you want to test. If you want to test all adUnits in the scene go to Adverty->Debug and click “Add ImpViz component to all units”.

    ○ When playing the application in Unity the ad units with impViz component attached will tint with impression color when the first ad impression is registered and tint with bounce back color each time it registers an impression after that. This gives a good understanding of how the ad unit should be designed and placed in the scene to generate impressions.

    Observe that ImpViz is availible for all units but MenuUnit will only be triggered on iOS devices. ViewedImpression event is availible for both unit types but Menuunit will only trigger impressions on iOS devices (Support for other platforms will be included in future releases).

    Lazy Load

    ■ Go to Tools > Adverty > Settings and yo have an option “Allow Lazy Load”. As default it is enabled. This feature helps you to optimize loading of ads. It will try to load ads as your player approaches the adunits. Each adunit also has an option “Disable Lazy Load” which overrides the global setting. Depending on how adunits is used in your game you might want to disable Lazy Load for a certain unit. As an example if you have a unit which is always visible you can disable Lazy Load for that unit. However, if you have an adunit which is only visible to users after some exploration of the map lazy load will help you to activate it only when users approaches the adunit in question.

    For static game worlds and units it is recomended to have Lazy Load enabled. For procedural created game worlds and units it should be disabled, since placements of units will vary for each run.

    Ad Unit Types

    ● In-Play™: Non-clickable game objects that can be placed on the scenes to help you monetize the gameplay.

    ● In-Menu™: Clickable UI objects that can be placed on any UI layer to seamlessly blend with menus. By default clicks open up native webview that keep users inside the application.

    In-Play™.GameUnit.prefab

    Previously called Unit.prefab (Deprecated)
    3 settings will affect the unit behavior:

    ● Allow Animation: If the unit can display both animated and static campaigns.

    ● Immediate Activation: Immediate activation allows refreshes on Ad Units to happen immediately instead of when ad unit is not being rendered. First activation is not affected by this setting.

    ■ NOTE: Ad Units refresh automatically within the 60s period (may vary), even if they were not activated, as long as session is live.

    ● Shader Type: Two shader types can be used. Unlit type will not be affected by lighting and will show the ad unit with the campaigns “true” colors. Lit type will be affected by lighting in the scene.

    General advices

    Adverty-sdk 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 unit. This makes it so that if the AdUnit is not receiving an ad your desired texture will be shown. If an ad is delivered your texture will be replaced by the ad. The ratio of the adUnits are 1.2:1, 1:2 or 16:9 for VR and AR and 1.2:1, 1:2 or 3.88:1 for Mobile. Here is how to do this.

    void Start()
        {
            unit.GetComponent<Renderer>().material.mainTexture = yourTexture;
        }

    Disable MeshRenderer

    You can disable the MeshRenderer on the Unit-prefab. When an ad is delivered the MeshRenderer is activated. This enables the AdUnit not to render in the game until an actual ad is delivered. You can do this either via the inspector or via code.

    void Start()
        {
            unit.GetComponent<MeshRenderer>().enabled = false;
        }

    Scripting API

    AdvertySDK

    void AdvertySDK.Init(UserData userData)

    To activate the AdvertySDK you need to call AdvertySDK.Init. Calling Init without any of the optional parameters will use the current configuration set on AdvertySettings and trigger an SDK sign in. If any of the data change you should call Adverty.Init again to have an Adverty session with the updated parameters. If you want more control of the data used to initialize your session you can use more parameters to the AdvertySDK.Init described further down

    Example with only required parameters:

    public class ActivateAdvertyExampleClass : MonoBehaviour
        {
            void Start()
            {
                UserData userData = new UserData(AgeSegment.Unknown, Gender.Unknown);
                Adverty.AdvertySDK.Init(userData);
    
                Adverty.AdvertySettings.SetMainCamera(YourGameCamera);
            }
        }
    
        

    void AdvertySDK.Init(string apiKey, AdvertySettings.Mode platform, bool restrictUserData, UserData userData)

    Initialize Adverty SDK using parameters. with this init call you control which API-key and platform that is used to set up the AdvertySession. You can achieve the same result by the simplier Init-call by assigning correct values to the parameters of AdvertySettings. Adverty SDK supports Consent strings from IAB Transparency and Consent Framework 2.0 which you add to the userData object before calling AdvertySDK.Init. Adverty’s vendor id is 822 in TCF 2.0

    Example 2 with optional parameters:

    public class ActivateAdvertyExampleClass : MonoBehaviour
        {
            void Start()
            {
                string apiKey = YOUR_API_KEY;
                Adverty.AdvertySettings.Mode platform =
                Adverty.AdvertySettings.Mode.Mobile;
                bool restrictPersonalData = false;
                UserData userData = new UserData(AgeSegment.Unknown, Gender.Unknown, "Consent strings from IAB Transparency and Consent Framework");
                Adverty.AdvertySDK.Init(apiKey, platform, restrictPersonalData, userData);
    
                Adverty.AdvertySettings.SetMainCamera(YourGameCamera);
    
            }
        }

    void AdvertySDK.Terminate()

    Terminates the current Adverty session, if any exists

    Example:

    public class DeactivateAdvertyExampleClass: MonoBehaviour
            {
                void Start()
                {
                    Adverty.AdvertySDK.Terminate();
                }
        }

    AdvertySettings

    AdvertySettings is keeping track of all information regarding how to set up an AdvertySession. When calling AdvertySDK.Init the SDK is updating AdvertySettings if optional paramaters was sent in and then using AdvertSettings to create an AdvertySession

    void AdvertySettings.SetAPIKey(string key)

    Sets the API-key property in AdvertySettings. This dosen’t trigger a new AdvertySDK.Init by itself, so make sure to call AdvertySDK.Init after changing API-key

    Example:

    public class ChangeAdvertyAPIKeyExampleClass : MonoBehaviour
                {
                    void Start()
                    {
                        AdvertySettings.SetAPIKey("YOUR_API_KEY")
    
                        UserData userData = new UserData(AgeSegment.Unknown, Gender.Unknown);
                        Adverty.AdvertySDK.Init(userData);
                    }
                }
    
                

    void AdvertySettings.SetMainCamera(Camera camera)

    Set the correct Main Camera through AdvertySettings.SetMainCamera(Camera camera). AdvertySDK incorporates camera and rendering calculations on the main camera. Use this method to specify the main game camera to the AdvertySDK. This is important to ensure revenue for your ad units.

    Example:

    public class OverrideAdvertyCameraExample : MonoBehaviour
                {
                    void Start()
                    {
                        Adverty.AdvertySettings.SetMainCamera(Camera.main);
                    }
                }

    void AdvertySettings.ClearAPIKey()

    Clears the API-key from AdvertySettings

    bool AdvertySettings.ValidateAPIKey(string key)

    Validates an API-key. Keys automaticly gets validated when you call AdvertySDK.Init or fill it in the AdvertyMenu (Tools->Adverty->Settings)

    UserData AdvertySettings.UserData

    Set and Get the UserData property. When you update it you need to call AdvertySDK.Init to create a new session and thus applying the change. Provide user data to the AdvertySDK to improve targeting and eCPM for the ads you can modify it in AdvertySettings.UserData.

    Example:

    public class ModifyUserDataExample : MonoBehaviour
                {
                    void Start()
                    {
                        UserData userData = new UserData(AgeSegment.Unknown, Gender.Unknown);
                        AdvertySettings.UserData = userData;
                    }
                }
                

    UserData constructor also includes an optional parameter for Consent strings from IAB Transparency and Consent Framework 2.0.

    Example:

    public class UserDataWithConsentStringExample : MonoBehaviour
                {
                    void Start()
                    {
                        UserData userData = new UserData(AgeSegment.Unknown, Gender.Unknown, "Consent strings from IAB Transparency and Consent Framework");
                        AdvertySettings.UserData = userData;
                    }
                }
                

    bool AdvertySettings.RestrictUserData

    If you want to block the AdvertySDK from collecting personal data from the user you can set restrictUserData to true and then call Adverty.Init to apply the changes. This will reduce the potential demand and reduce the overall revenue.

    Example:

    public class RestrictUserDataExample : MonoBehaviour
                {
                    void Start()
                    {
                        Adverty.AdvertySettings.RestrictUserData = true;
                    }
                }
                

    string AdvertySettings.APIKey

    Set and Get the API-key of AdvertySettings.

    Mode AdvertySettings.Platform

    Set and Get the platform of AdvertySettings. Call AdvertySDK.Init to apply the changes. If you have multiple modes in a game. For example a 360 view and a VR mode, it is possible to switch the platform of the Adverty SDK.

    Example:

    public class ChangeModeExample : MonoBehaviour
                {
                    void Start()
                    {
                        Adverty.AdvertySettings.Platform = Mode.Mobile; //Mode.AR, Mode.VR
                    }
                }
                

    bool AdvertySettings.IsLazyLoadAllowed

    Set and Get the IsLazyLoadAllowed of AdvertySettings. Call AdvertySDK.Init to apply the changes

    ClickHandlingType AdvertySettings.ClickHandling

    Set and Get the ClickHandling of AdvertySettings. This decides how to open fullscreen ads after Interacting with MenuUnits. Internal means that we open an overlay inside the app, external and ad will open in external browser.

    Example:

    public class ChangeClickHandlingExample : MonoBehaviour
                {
                    void Start()
                    {
                        Adverty.AdvertySettings.ClickHandling = ClickHandlingType.Internal; //ClickHandlingType.External
                    }
                }
                

    AdvertyEvents

    AdvertyEvents is a collection of events where you can subscribe on certain events to do things dependeing on the flow of Adverty SDK.

    event Action AdvertyEvents.AdvertySessionActivated

    AdvertySessionActivated fires when an AdvertySession is created successfully.  Best practice should be to start initiating units when you have an activated session

    event Action AdvertyEvents.AdvertySessionActivationFailed

    FailedAdvertySessionActivation fires if an Adverty Session fails to activate.

    event Action AdvertyEvents.AdvertySessionTerminated

    Event fires when an Adverty session is terminated

    event Action <BaseUnit> AdvertyEvents.AdDelivered

    Every ad unit will request ads and when a Unit has got an ad AdDelivered will execute this will be done before the units activates and it can still fail to activate due to for example an issue in the ad itself. It returns a BaseUnit which is the parent to the GameUnit and MenuUnit.

    In contrast to the other Unit events this event is about the ads and gets triggered every time a new ad is loaded for a unit, even if the unit itself don’t deactivate or active to show the ad.

    Example:

    public class AdDeliveredExampleClass : MonoBehaviour
                        void Start()
                        {
                            Adverty.AdvertyEvents.AdDelivered += AdDelivered;
                        }
    
                        private void AdDelivered(Adverty.BaseUnit  unit)
                        {
                            //ADD ACTION ON AD DELIVERED IF NEEDED
                        }
    
                    

    event Action <BaseUnit> AdvertyEvents.UnitActivated

    Every ad unit will request ads and UnitActivated will execute when the unit start to show ads. It returns a BaseUnit which is the parent to the GameUnit and MenuUnit.

    This event will fire every time a unit goes from deactivated to active

    Example:

    public class UnitActivatedExampleClass : MonoBehaviour
                    void Start()
                    {
                        Adverty.AdvertyEvents.UnitActivated += UnitActivated;
                    }
    
                    private void UnitActivated(Adverty.BaseUnit  unit)
                    {
                        //ADD ACTION ON UNIT ACTIVATION IF NEEDED
                    }
    
                

    event Action <BaseUnit> AdvertyEvents.UnitActivationFailed

    Every ad unit will request an ad and if it don’t recieve an ad or fails to render it UnitActivationFailed will fire. It returns a BaseUnit which is the parent to the GameUnit and MenuUnit.

    Example:

    public class UnitActivationFailedExampleClass : MonoBehaviour
                    void Start()
                    {
                        Adverty.AdvertyEvents.UnitActivationFailed += UnitActivationFailed;
                    }
    
                    private void UnitActivationFailed(Adverty.BaseUnit  unit)
                    {
                        //ADD ACTION ON UNIT ACTIVATION FAILED IF NEEDED
                    }
    
                

    event Action <BaseUnit> AdvertyEvents.UnitDeactivated

    When a unit gets deactivated UnitDeactivated will fire. This happens when a unit has been active and the lifespan of the ad reaches its end. Unit will keep the texture after this event but cannot be registered as viewed anymore. Unit will automaticly try to refresh and might get a new ad, otherwise UnitActivationFailed will get triggered. It will also get triggered when the AdvertySession has been terminated. It returns a BaseUnit which is the parent to the GameUnit and MenuUnit

    Example:

    public class UnitDeactivatedExampleClass : MonoBehaviour
                    void Start()
                    {
                        Adverty.AdvertyEvents.UnitDeactivated += UnitDeactivated;
                    }
    
                    private void UnitDeactivated(Adverty.BaseUnit  unit)
                    {
                        //ADD ACTION ON UNIT DEACTIVATED IF NEEDED
                        //Example of action can be to hide unit or apply your own texture to it
                    }
    
                

    event Action <BaseUnit> AdvertyEvents.UnitViewed

    UnitViewed gets triggered when an ad is considered viewed by our patented viewability solution BrainImpression. This is crucial for increasing the value of your ads as advertisers pay more for ads where they have good viewability. It returns a BaseUnit which is the parent to the GameUnit and MenuUnit.

    UnitViewed can be triggered several times per Unit since same unit can show more than one ad during the lifespan of the unit

    Example:

    public class UnitViewedExampleClass : MonoBehaviour
                    void Start()
                    {
                        Adverty.AdvertyEvents.UnitViewed += UnitViewed;
                    }
    
                    private void UnitViewed(Adverty.BaseUnit  unit)
                    {
                        //ADD ACTION ON UNITVIEWED IF NEEDED
                    }
    
                

    event Action <BaseUnit> AdvertyEvents.AdCompleted

    AdCompleted gets triggered when an ad is completed for the first time. This means that a MenuUnit has been interacted and that the fullpage webview has been shown. Event gets triggered when the user returns to your game. It returns a BaseUnit which is the parent to the GameUnit and MenuUnit.

    AdCompleted can be triggered several times per MenuUnit since same unit can show more than one ad during the lifespan of the unit

    Example:

    public class AdCompletedExampleClass : MonoBehaviour
                        void Start()
                        {
                            Adverty.AdvertyEvents.AdCompleted += AdCompleted;
                        }
    
                        private void AdCompleted(Adverty.BaseUnit  unit)
                        {
                            //ADD ACTION ON AD COMPLETED SUCH AS A REWARD
                        }
    
                    

    event Action WebViewOpened

    WebViewOpened gets triggered when a MenuUnit has been interacted and an internal webview has been opened. At this point it is recomended to pause gameplay.

    Example:

    public class WebViewOpenedExampleClass : MonoBehaviour
                    void Start()
                    {
                        Adverty.AdvertyEvents.WebViewOpened += WebViewOpened;
                    }
    
                    private void WebViewOpened()
                    {
                        //ADD ACTION ON WebViewOpened IF NEEDED
                    }
    
                

    event Action WebViewClosed

    WebViewClosed gets triggered when a Menuunit has been interacted and an internal webview has been closed. At this point it is recomended to unpause gameplay.

    Example:

    public class WebViewCloseddExampleClass : MonoBehaviour
                    void Start()
                    {
                        Adverty.AdvertyEvents.WebViewClosed += WebViewClosed;
                    }
    
                    private void WebViewClosed()
                    {
                        //ADD ACTION ON WebViewClosed IF NEEDED
                    }
    
                

    NOTE: If your rewards includes visuals and some in-game event, this should be executed on AdvertyEvents.WebViewClosed. However, the reward should be given on AdvertyEvents.AdCompleted. (WebViewClosed can be triggered without AdCompleted being triggered. For example if the user decides to cancel the ad before it finished and close the ad overlay)

    NOTE 2: These campaigns uses a native overlay for Android/iOS to display the webview. That means it is not possible to test the full flow inside Unity Editor. This requires running on an Android/iOS device.

    event Action <BaseUnit> AdvertyUnitActivated

    Deprecated. Use UnitActivated.

    Every ad unit will request an ad when it is initiated and AdvertyUnitActivatedEvent will execute when a campaign has been delivered and loaded to the ad unit. AdConfiguration includes information about if the campaign is interactable and/or animated.

    Example:

    void Start()
                {
                    Adverty.AdvertyEvents.AdvertyUnitActivated += AdvertyUnitActivated;
                }
    
                private void AdvertyUnitActivated(Adverty.Unit  unit, Adverty.AdUnit.AdConfiguration configuration)
                {
                    //ADD ACTION ON UNIT ACTIVATION IF NEEDED
                }
    
                Class AdConfiguration
                {
                    bool Interactable;
                    bool Animated;
                }

    event Action <BaseUnit> AdvertyUnitFailedActivationEvent

    Deprecated. Use UnitActivationFailed.

    Every ad unit will request an ad when it is initiated. If no ad is delivered to an ad unit AdvertyUnitFailedActivationEvent will execute.

    Example:

    void Start()
        {
            Adverty.AdvertyEvents.AdvertyUnitFailedActivationEvent += FailedActivation;
        }
    
        private void FailedActivation(Adverty.BaseUnit unit)
        {
            //ADD ACTION ON UNIT FAILED ACTIVATION IF NEEDED
        }
    
        

    event Action <BaseUnit> AdvertyUnitDeactivatedEvent

    Deprecated. Use UnitActivationFailed.

    Ad units has life cycles and can after a certain time become deactivated and request new campaigns. AdvertyUnitDeactivatedEvent fires when an ad unit is deactivated.

    Example:

    void Start()
        {
            Adverty.AdvertyEvents.AdvertyUnitDeactivatedEvent += UnitDeactivated;
        }
    
        private void UnitDeactivated(Adverty.BaseUnit  unit)
        {
            //ADD ACTION ON UNIT DEACTIVATION IF NEEDED
        }

    event Action <BaseUnit> AdvertyViewedImpression

    Deprecated. Use UnitViewed.

    Callback to understand when an adunit is considered as viewed. This is only called first time a unit is viewed by the user.

    Example:

    void Start()
        {
            Adverty.AdvertyEvents.AdvertyViewedImpression += UnitViewed;
        }
    
        private void UnitViewed(Adverty.BaseUnit  unit)
        {
            //ADD ACTION ON UNIT VIEWED IF NEEDED
        }

    AdvertyEvents.WebViewOpenedEvent

    Deprecated. Use WebViewOpened.

    As the video and store landing page will be shown in fullscreen over your application there is an event that triggers when this overlay is opened. This can be used if your application requires for example pausing. Here follows a code snippet showing how to use it.

    Example:

    void Start()
        {
            Adverty.AdvertyEvents.WebViewOpenedEvent += Pause;
        }
    
        private void Pause()
        {
            //PAUSE THE GAME
        }
        

    AdvertyEvents.WebViewClosedEvent

    Deprecated. Use WebViewClosed.

    Whenever the fullscreen overlay is closed the WebViewClosedEvent triggers. If you have paused the game this is probably when you want to resume it. Here follows a code snippet showing how to use it.

    Example:

    void Start()
        {
            Adverty.AdvertyEvents.WebViewClosedEvent += Resume;
        }
    
        private void Resume()
        {
            //RESUME THE GAME
        }
        

    NOTE: If your rewards includes visuals and some in-game event, this should be executed on AdvertyEvents.WebViewClosedEvent. However, the reward should be given on AdvertyEvents.AdCompleted. (WebViewClosedEvent can be triggered without AdCompleted being triggered. For example if the user decides to cancel the ad before it finished and close the ad overlay)

    NOTE 2: These campaigns uses a native overlay for Android/iOS to display the webview. That means it is not possible to test the full flow inside Unity Editor. This requires running on an Android/iOS device.

    AdvertyEvents.AdvertyAdDelivered

    Deprecated. Use AdDelivered.

    Every ad unit will request an ad when a Unit has got an ad AdvertyAdDelivered will execute this will be done before the units activates and it can still fail to activate due to for example an issue in the ad itself. It returns a BaseUnit which is the parent to the GameUnit and MenuUnit.

    Example:

    public class AdvertyAdDeliveredExampleClass : MonoBehaviour
                    void Start()
                    {
                        Adverty.AdvertyEvents.AdvertyAdDelivered += AdvertyAdDelivered;
                    }
    
                    private void AdvertyAdDelivered(Adverty.BaseUnit  unit)
                    {
                        //ADD ACTION ON AD DELIVERED IF NEEDED
                    }
    
                

    AdvertyEvents.AdvertyAdCompleted

    Deprecated. Use AdCompleted.

    Every ad unit will request an ad when a Unit has got an ad AdvertyAdCompleted will execute this will be done before the units activates and it can still fail to activate due to for example an issue in the ad itself. It returns a BaseUnit which is the parent to the GameUnit and MenuUnit.

    Example:

    public class AdvertyAdCompletedExampleClass : MonoBehaviour
                        void Start()
                        {
                            Adverty.AdvertyEvents.AdvertyAdCompleted += AdvertyAdCompleted;
                        }
    
                        private void AdvertyAdCompleted(Adverty.BaseUnit  unit)
                        {
                            //ADD ACTION ON AD COMPLETED SUCH AS REWARD
                        }
    
                

    Programmatic setup of adunits (UnitFactories)

    To instantiate units during runtime you can of course instantiate the Gameunit.prefab or MenuUnit.prefab but you can also use the Adverty.GameUnitFactory or MenuUnitFactory class.  

    Create method of any of the factories will return a unit gameobject of the specific type, configuration with the optional parameters Mesh and GameObject name.

    GameUnitFactory
    Example without optional parameters:

    public class GameUnitInstantiateExampleClass : MonoBehaviour
                {
                    void Start()
                    {
                        Adverty.AdUnit.GameUnitConfiguration config = new Adverty.AdUnit.GameUnitConfiguration();
                        config.MeshData.Size = 1f;
                        config.MeshData.Ratio = Adverty.AdUnit.MeshData.UnitRatio.Box;
                        config.Behavior.AllowAnimation = true;
                        GameObject unit = Adverty.AdUnit.GameUnitFactory.Create(config);
                    }
                }
    
                

    Example with optional parameters:

    public class UnitInstantiateExampleClass : MonoBehaviour
                {
                    public Mesh bentAdvertyMesh;
                    void Start()
                    {
                       Adverty.AdUnit.GameUnitConfiguration config = new Adverty.AdUnit.GameUnitConfiguration();
                        config.MeshData.Size = 1f;
                        config.MeshData.Ratio = Adverty.AdUnit.MeshData.UnitRatio.Box;
                        config.Behavior.AllowAnimation = true;
                        GameObject unit = Adverty.AdUnit.GameUnitFactory.Create(config, bentAdvertyMesh, "CustomName");
                    }
                }

    MenuUnitFactory 
    Example without optional parameters:

    public class MenuUnitInstantiateExampleClass : MonoBehaviour
                {
                    void Start()
                    {
                        Adverty.AdUnit.MenuUnitConfiguration menuConfig = new Adverty.AdUnit.MenuUnitConfiguration();
                        menuConfig.SizeData.Size = 1f;
                        menuConfig.SizeData.MatchWidthOrHeight = Adverty.AdUnit.MeshData.WidthHeight.Width;
                        GameObject unit = Adverty.AdUnit.MenuUnitFactory.Create(menuConfig);
                    }
                }
    
                

    Example with optional parameters:

    public class UnitInstantiateExampleClass : MonoBehaviour
                {
                    public Texture defaultTexture;
                    void Start()
                    {
                        Adverty.AdUnit.MenuUnitConfiguration menuConfig = new Adverty.AdUnit.MenuUnitConfiguration();
                        menuConfig.SizeData.Size = 1f;
                        menuConfig.SizeData.MatchWidthOrHeight = Adverty.AdUnit.MeshData.WidthHeight.Width;
                        GameObject unit = Adverty.AdUnit.UnitFactory.Create(config,"CustomName", defaultTexture);
                    }
                }

    The defaultTexture will be shown on adunit before an ad is loaded or if the unit is not filled with an ad for some reasons.

    • iab
    • iab
    • Tag
    • IAB Europe