Vungle inspires ad access - in the vernacular, teach you how to make a series.

Keywords: SDK

First, Vungle is an ad plug-in. It seems that for the time being, only video incentive advertising is supported.
Then, the application ID is not repeated. Note that Vungle needs to apply for two IDs. Corresponds to the ID of the environment initialization and the "VunglePlacementID".
It's still two steps to start accessing Vungle's video advertising.
Step 1: import the plug-in. Download address
Import the VunglePlugin-x.x.x.unitypackage file you downloaded into your project.
The following file appears.

The first step is done.

Step 2, code part

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class VungleAd : MonoBehaviour {

    // Use this for initialization
    void Start()
        Debug.Log("vungle init");
        //Multiple "vungleplacementids" can be added
        Dictionary<string, bool> placements = new Dictionary<string, bool>
             { "VunglePlacementID", false }
        string[] array = new string[placements.Keys.Count];
        placements.Keys.CopyTo(array, 0);
        //Ad instantiation, once.
        Vungle.init("VungleAndroidAppId", array);

    // Update is called once per frame
    void Update () {

    //Advertisement corresponding event.
    /* Setup EventHandlers for all available Vungle events */
    void initializeEventHandlers()
        Vungle.adPlayableEvent += (placementID, adPlayable) => {
            if (placementID == "VunglePlacementID")
               //Judge whether the advertisement is loaded
        //Event triggered during when an ad is about to be played
        Vungle.onAdStartedEvent += (placementID) => {
            Debug.Log("Ad " + placementID + " is starting!  Pause your game  animation or sound here.");

        //Event is triggered when a Vungle ad finished and provides the entire information about this event
        //These can be used to determine how much of the video the user viewed, if they skipped the ad early, etc.
        Vungle.onAdFinishedEvent += (placementID, args) => {
            Debug.Log("Ad finished - placementID " + placementID + ", was call to action clicked:" + args.WasCallToActionClicked + ", is completed view:"
                + args.IsCompletedView);
            if (args.IsCompletedView)
                //Finish watching, reward logic

        //Event is triggered when the ad's playable state has been changed
        //It can be used to enable certain functionality only accessible when ad plays are available
        Vungle.adPlayableEvent += (placementID, adPlayable) => {
            Debug.Log("Ad's playable state has been changed! placementID " + placementID + ". Now: " + adPlayable);
            //placements[placementID] = adPlayable;

        //Fired log event from sdk
        Vungle.onLogEvent += (log) => {
            Debug.Log("Log: " + log);

        //Fired initialize event from sdk
        Vungle.onInitializeEvent += () => {
            //adInited = true;
            Debug.Log("SDK initialized");

    //The loading method adUnitId is to fill in the corresponding "VunglePlacementID"
    public void LoadRewardAd(string adUnitId)
    //Display incentive ads
    public void ShowRewardAd(string adUnitId)
        //Vungle.isAdvertAvailable(adUnitId) determines whether the corresponding ID advertisement can be displayed.
        if (Vungle.isAdvertAvailable(adUnitId))


For novices, you can replace the ID ("vungleandroid appid") and "vungleplacement ID" of the environment initialization corresponding to the above code with your own ID.
Code part complete.
Request advertisement through LoadRewardAd(string adUnitId) method
Just display the advertisement by ShowRewardAd(string adUnitId) method.
Old bird's words can be referred to Official documents of Vungle and Getting Started Guide To optimize your code.

Posted by jacksonpt on Sat, 02 May 2020 09:47:29 -0700