Meet the OmniVirt's Unity VR Ad SDK. OmniVirt Ad Network is VR Advertising Network which enables developers and publishers to monetize their apps/games with seamless and engaging VR experiences.
Simply integrate the OmniVirt Unity Ad SDK into your Unity application/game and get paid for presenting sponsored 360° video experiences and/or in-game billboard ad to your users. Backfill your inventory with premium CPM experiences from OmniVirt’s network of advertisers. We support both 360° and 2D video ads inside VR apps.
OmniVirt Unity Ad SDK could be used on Unity 5.4 or newer.
Latest version of OmniVirt Unity Ad SDK is v2.5.3 (Nov 15, 2018)
There are two formats of Ad available in OmniVirt Unity Ad SDK
- Billboard Ad - Provide the billboard ad that can be shown seemlessly with your game scene.
- Fullscreen Ad - Provides the skippable immersive fullscreen video ad for your game.
Now let us show you how easy you could integrate our Ad SDK to your game!
Do the following steps to create an app and the first ad space associated in the OmniVirt system.
- Sign up for an account at OmniVirt.
- Go to My Apps page under Dashboard and click at Submit App button.
- Fill in your VR app's name and click next.
- Fill in your first Ad Space details, choose the Ad Format you wish to use for this Ad Space. If you want to go for the fullscreen ad one, please choose VR Full-Screen. In case you want to integrate the billboard ad, choose the orientation that fit your ad unit in the scene best either horizontal or vertical one. Please note that you can create more Ad Space for your app later. This is just the first one. After everything is filled, click at Finish
- Keep the AdSpace ID assigned for further use. Don't use the number being shown here, please use yours otherwise the ad revenue will not go to your account.
Now an Ad Space is ready. Next step is to enable the Ad on your application/game.
-
Download OmniVirtSDK.unitypackage
-
Import it to your Unity project via Assets -> Import Package -> Custom Package menu.
Your project will now contain all necessary files to integrate OmniVirt Unity VR ads in your game.
Currently OmniVirt Ad Network for Unity is supported only on iOS and Android. So to make it works, you need to switch platform to either iOS or Android first. To do so, click at File -> Build Settings, choose your target platform (iOS or Android) and then click Switch Platform.
Please note that if you do not switch the platform, your code will not be able to compile.
Here is the steps to integrate the billboard ad to your game scene.
Before going to the next step, please make sure that you have already created an app and an ad space with VR Billboard ad format with the desired orientation since Ad space ID with the correct format is required.
First let's prepare the script to put our logic code inside. To do so, let's create an empty GameObject in the scene.
And then, create a C# script and rename it to BillboardAdControl
.
Drag the script and drop it on a created GameObject to assign it to the scene.
Open BillboardAdControl.cs
file and add the following line in the header area.
using OmniVirt;
Declare BillboardAd
variable and initialize in Start()
function.
public class BillboardAdControl : MonoBehaviour {
public GameObject adPlane;
BillboardAd billboardAd;
// Use this for initialization
void Start () {
billboardAd = new BillboardAd(AD_SPACE_ID);
billboardAd.LoadAd(adPlane);
}
// Update is called once per frame
void Update () {
}
}
Please note that your must replace AD_SPACE_ID
with one you got from step above.
Billboard Ad plane is needed to be placed on your scene as a unit to show our loaded Billboard Ad. These planes are come along with the SDK as Prefabs. The horizontal one is called OmniVirtBillboardAdHorizontalPlane
while the vertical one is OmniVirtBillboardAdHorizontalPlane
.
Now just drag a Prefab with orientation corresponding to the ad space format you created previously to the scene.
Now drag the plane to the BillboardAdControl script added to empty GameObject previously.
Done!
If you do everything correctly, Billboard Ad should now be shown on the plane placed in your scene.
That's all! Please note that ad stat will be collected only when ad is shown for more than 10% of screen space so try to place the ad plane at the place that user may walk pass frequent to maximize the ad performance.
Please follow the instructions in this section to enable fullscreen ad in your app.
As same as the billboard ad one, before going to the next step, please make sure that you have already created an app and an ad space with VR Full-Screen ad format since Ad space ID with the correct format is required.
First let's prepare the script to put our logic code inside. To do so, let's create an empty GameObject in the scene.
And then, create a C# script and rename it to AdNetworkControl
.
Drag the script and drop it on a created GameObject to assign it to the scene.
Open AdNetworkControl.cs
file and add the following line in the header area.
using OmniVirt;
Declare VRAd
variable and initialize in Start()
function.
public class AdNetworkControl : MonoBehaviour {
VRAd vrAd;
// Use this for initialization
void Start () {
vrAd = new VRAd (AD_SPACE_ID); // Replace your Ad Space ID here
// Register a Callback
vrAd.AdStatusChanged += OnAdStatusChanged;
}
// Update is called once per frame
void Update () {
}
void OnAdStatusChanged() {
}
}
Please note that your must replace AD_SPACE_ID
with one you got from step above.
Ad must be loaded first before it could be shown. Call LoadAd()
like shown below to start loading.
// Use this for initialization
void Start () {
vrAd = new VRAd (AD_SPACE_ID); // Replace your Ad Space ID here
// Register a Callback
vrAd.AdStatusChanged += OnAdStatusChanged;
// Prepare an Ad
vrAd.LoadAd();
}
Ad will now be loaded in the background and once it is ready, OnAdStatusChanged
will be called with Ready
state. Please note that the whole video file of the ad will be downloaded before changing the state. This will make the ad be able to play at super efficient performance in your app. Cache is also implemented so the next time the same ad is requested, it will use the local file instead of downloading the same file again.
If you want ad to start playing automatically, just add the following code snippet to the callback function.
...
void OnAdStatusChanged() {
if (vrAd.IsReady ()) {
vrAd.Show (false);
}
}
...
You can trig the ad to be displayed in VR Mode by passing a parameter in show()
function like shown below.
vrAd.Show (true);
With this feature, you will be able to make Ad show with seamless experience as your VR app / game.
And that's all ... done! Please run your code and see if everything is working correctly. Expected result is Fullscreen Ad should be shown at the place you call Show
function. Easy, huh? =D
LoadAd()
is needed to be called once per ad served. You can reload an ad to make it ready for the next session by implementing the code inside OnAdStatusChanged
like shown below.
...
IEnumerator ReloadAd() {
yield return null;
if (vrAd != null) {
vrAd.Unload ();
vrAd = null;
}
vrAd = new VRAd (AD_SPACE_ID); // REPLACE YOUR AD_SPACE_ID HERE
vrAd.AdStatusChanged += OnAdStatusChanged;
vrAd.LoadAd ();
}
void OnAdStatusChanged() {
if (vrAd.IsCompleted ()) {
// Reload an ad for next session
StartCoroutine (ReloadAd ());
}
}
...
When the state of VRAd has been changed, OnAdStatusChanged
callback function will be called with the new state in the AdStatusChangedEventArgs
parameter.
...
void OnAdStatusChanged() {
// New AdState could be retrieved from vrAd.adState
}
...
There are different 5 states in total.
-
AdState.Loading - Ad is being loaded in the background.
-
AdState.Ready - Ad is ready to be shown. You can call
Show()
function at this state to display the loaded ad. -
AdState.Showing - Ad is being displayed.
-
AdState.Completed - Ad display is finished.
-
AdState.Failed - Ad could not be loaded.
On Android, back button is needed to be handled to prevent unexpected behavior.
void Update () {
// Handle Back Button
if (Input.GetKeyDown (KeyCode.Escape)) {
// If Ad is being shown, it will be automatically hide.
// Don't do anything.
if (vrAd.IsShowing ())
return;
// Else, do whatever you want, for example, quit the app
//Application.Quit ();
}
}
Since Day Dream game controller support is required on Day Dream compatible application / game, OmniVirt SDK also provides support on this funcionality as well. You can enable it with some easy following steps.
-
Import Google VR SDK for Unity into your project. If your application or game is built for Day Dream, it supposes to have this SDK installed in your project already.
-
Add
GvrControllerMain
andGvrEditorEmulator
prefab to the scene.
- Add
OmniVirtGameController
script toGvrControllerMain
game object. (It is important to add script to the correct one otherwise it would not work).
That's all. Day Dream controller will now magically work with our VR Player in Day Dream mode !
Bitcode is not supported on OmniVirt SDK yet. Please turn the Bitcode off by set Build Settings -> Bitcode
to off for your deployment target.
If you have any question, please don't hesitate to email us at adnetwork@omnivirt.com !