Requirements
● Officially released Unity versions 5.6.3 or later.
● 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
- ■ Android, Linux and Windows platforms using Vulkan API
- ■ Modern Open GL platforms (Open GL 4.3 for windows and Open GL ES 3.1 for Android)
● Android 5.0 (build support from Android 4.0) together with above requirements
● iOS 8 (build support from iOS 7) together with above requirements
If you are building an Android application and want to test your application in the Unity editor, it is a requirement to use DirectX11 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.
Running the editor on Mac will work if you are running the Metal Editor Support (see Player settings->Other Settings).
Setup SDK
Import the SDK
● Download and extract the Unity SDK from the link you were given in your registration mail.
● Drag and drop the “adverty” folder in your Unity project.
Setup the SDK
- ■ Click the dropdown Adverty > Settings and select the platform for your application (AR, VR or Mobile). Then add the two application keys provided to you in your registration mail, one for “RELEASE” and one for “SANDBOX”. If no key is supplied no ads will be loaded to the project.
- ■ Use Sandbox mode when testing your application and for test builds. Your Release build will require the Environment switch to be set to “RELEASE” in order for live adverts to be sent to your application and for you to start earning revenue. The selected Environment mode will be used when building your application. In Unity-mode, Sandbox will always be used.
Campaign Types
● Attract: This stage will support static or animated campaigns. Revenue is based on CPM model
● Engage: This stage will support viewable and interactable content. For example videos and 360 videos. Revenue is based on a combination of a CPM and CPC model
● Commit: This stage will support actions of the user. For example download an app or register on a website. Revenue is based on a combination of a CPM, CPC and CPA model.
Unit.prefab
3 settings will affect the unit behavior.
● Allow Interaction: If the unit can be interactable and is allowed to be served Engage campaigns. This enables higher revenue possibilities.
● Allow Animation: If the unit can display both animated and static campaigns in the Attract stage.
● Immediate Activation: If the unit should update with a new campaign if it is visible in the application. This options controls when the ad unit will update the surface with an incoming campaign. Without “immediate activation” the unit will only update the unit surface when outside of user vision. This option can depending on the setup of you application hinder ad units from becoming active and generating revenue. But if it is important that an image is not loaded onto an ad unit when in vision of the user, this option handles that.
Interactable ads (currently only available for AR and mobile):
With “Allow Interaction” enabled it is possible but not guaranteed to receive an interactable ad. An interactable ad will provide one campaign including up to all 3 stages of content (Attract, Engage and Commit). It starts with the Attract stage, but when the unit is interacted with it will iterate through the different stages described above. Revenue will be generated based on a combination of CPM, CPC and CPA models.
To interact with a unit the interact function must be called. What will trigger the interaction is up to you.
void YourIntearctionEvent()
{
unit.Interact();
}
Setup AdUnits
● Add an ad unit to your scene
○ Locate the Unit.prefab in 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.
○ Snap the ad unit 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.
● 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.
○ 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.
● Test your ad units with real-time impression indicator
○ 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.
○ 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.
Adverty Events
AdvertyEvents. UnitActivatedEvent
Every ad unit will request an ad when it is initiated and UnitActivatedEvent will execute when a campaign has been delivered and loaded to the ad unit.
void Start()
{
Adverty.AdvertyEvents.UnitActivatedEvent += UnitActivated;
}
private void UnitActivated(Adverty.Unit unit)
{
//ADD ACTION ON UNIT ACTIVATION IF NEEDED
}
AdvertyEvents. UnitFailedActivationEvent
Every ad unit will request an ad when it is initiated. If no ad is delivered to an ad unit UnitFailedActivationEvent will execute
void Start()
{
Adverty.AdvertyEvents.UnitFailedActivationEvent += FailedActivation;
}
private void FailedActivation(Adverty.Unit unit)
{
//ADD ACTION ON UNIT FAILED ACTIVATION IF NEEDED
}
AdvertyEvents. UnitDeactivatedEvent
Ad units has life cycles and can after a certain time become deactivated and request new campaigns. UnitDeactivatedEvent fires when a ad unit is deactivated.
void Start()
{
Adverty.AdvertyEvents.UnitDeactivatedEvent += UnitDeactivated;
}
private void UnitDeactivated(Adverty.Unit unit)
{
//ADD ACTION ON UNIT DEACTIVATION IF NEEDED
}
Unit Interaction
The interactable unit is a great possibility for you to utilize rewarded ads. Rewarded ads is a concept when the user is rewarded for fulfilling an interaction with an ad. The reward is up to you to define. It can be a virtual currency, in-game goods for the application or something else. To use this functionality there are three public events to your exposal in AdvertyEvents.
AdvertyEvents. VideoDoneEvent
When a user has watched the entire video ad this event will trigger. The event returns the Unit component of the completed adUnit. Here follows a code snippet showing how to use it.
void Start()
{
Adverty.AdvertyEvents.VideoDoneEvent += Reward;
}
private void Reward(Adverty.Unit unit)
{
//GIVE THE REWARD TO THE USER
}
AdvertyEvents. WebViewOpenedEvent
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.
void Start()
{
Adverty.AdvertyEvents.WebViewOpenedEvent += Pause;
}
private void Pause()
{
//PAUSE THE GAME
}
AdvertyEvents. WebViewClosedEvent
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.
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 still be given on Unit.onVideoDone. (WebViewClosedEvent can be triggered without VideoDoneEvent being triggered. For example if the user decides to cancel the video 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.
General advices
Adverty-sdk requires internet to load ads programmatically 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;
}