VIRE SDK with other ad solutions

In the normal case the ad starts immediately after the ad request was successful. The VIRE ad solution has the advantage that it is ready to combine with other ad solutions. In this case you do not want to start the ad automatically after the ad request. Therefor you can set autoAdStart = false in the AdOptions.

If autoAdStart = false, the callback function will be called twice. First time after the request is executed with the parameters AdResult.HasAd or AdResult.NoAd. If an Ad is available you can call VIRE.startAd() to start the ad manually. After the ad was shown the callback function will be called a second time with the parameter AdResult.Finished or AdResult.Skipped.

The code below shows an example:

using UnityEngine;
using Vire;

public class AdManager : MonoBehaviour
{
    private void Start()
    {
        VIRE.init("3e6d0d66-0a1c-447b-b552-e42611e1d7af");
    }

    public void showAd()
    {
        AdOptions options = new AdOptions { callback = myCallback, autoAdStart = false };
        StartCoroutine(VIRE.requestAd(options));
    }

    private void myCallback(AdResult result)
    {
        switch (result)
        {
            case AdResult.HasAd:
                Debug.Log("Callback - Ad Available.");  
                myStartAd();
                break;
            case AdResult.NoAd:
                Debug.Log("Callback - No ad Available.");
                break;
            case AdResult.Finished:
                Debug.Log("Callback - The ad was successfully shown.");
                break;
            case AdResult.Skipped:
                Debug.Log("Callback - The ad was skipped before reaching the end.");
                break;
            case AdResult.Failed:
                Debug.LogError("Callback - The ad failed to be shown.");
                break;
        }
    }

    private void myStartAd()
    {
       VIRE.startAd();
    }
}

Disable auto manifest post processing

If you do not want to add the required options automatically to your manifest you can add them manually. Therefor you need to delete the folder "Assets/VIRE Plugin/Scripts/BuildPostProcessing". In every vire update the file has to be deleted. Now you have to add the <activity>, <service> and the <permission> to your manifest file by copying them from the code example below.

<manifest>
  <application>

  ...

    <activity android:name="com.vire.vire_library.VIRE_Activity"
              android:screenOrientation="landscape"
              android:hardwareAccelerated="true" />

    <service android:name="com.vire.vire_library.VIRE_Service"
             android:enabled="true"
             android:exported="true" />

  ...

  </application>

  ...

  <uses-permission android:name="android.permission.INTERNET" />

  ...

</manifest>

Examples for Google Cardboard, Daydream and Gear VR controller

We want to make the integration of VIRE ads as easy as possible so we created an example project which shows the usage of placeable 3D objects to integrate our ad room solution. We created an unity prefab which enables you to trigger VIRE ad rooms by pointing and clicking with Google Cardboard, Daydream or Gear controllers.

In the example package are two scenes, one is setup for Google Cardboard and Daydream, the other for Oculus Gear. To get the scenes running, you need to:

(1) Download and import the vire-examples-0.1.0 package into a new Unity project.

(2) Create a new App in your VIRE account with a proper PlayStore ID. If you are not registered or don't know how to create a new app entry, please follow the steps in the getting started section.

(3) In your Unity project, enter the new app UUID in VIRE Examples -> Scripts -> VIRE_Admanager.js and switch the platform to Android.

(4) Go to your Player Settings, set them up like this and don't forget to update the Package Name:

Import Picture

To run the Google Cardboard and Daydream example, go to your Build Settings and add the Cardboard Daydream example as the active scene and change the minimum API level in your player settings to "Android 7.0 'Nougat' (API level 24)" for Daydream or "Android 4.4 'Kit Kat' (API level 19)" for Cardboard.

For running the Gear example, set the Gear example as the active scene and don't forget to sign your application by placing an osig file in Plugins -> Android -> assets which you can generate over here: Osig-generator. Here, the minimum API level is "Android 4.4 'Kit Kat' (API level 19)".

The prefabs under VIRE Example -> Prefabs can be used as a pattern for new ad placements in your scene. You could exchange the 3D model or the behaviour when a pointer enters the collider of the object. If you would like to integrate VIRE ad room placements into your existing project, you need to trigger the Pointer Enter/Exit and Click events on our prefabs to trigger ads. Please note that we have added a script called VIRE_Raycaster to the GearVrController which calls the proper pointer events.