Vungle Unity plugin supports Unity version 2022.3.62f1, and contains Windows SDK v7.0.0.
Download the Vungle Plugin for Unity
Reference: Sample App
Refer to the sample app we have provided as you integrate:
Step 1. Target the Correct Platform in Your Build Settings
To avoid compilation errors during the next step, make sure that your project Build Settings (cmd + Shift + B) are targeting the ✅ Windows platform and not the ❌ Unified Windows Platform (UWP).
Step 2. Update Vungle SDK Build and Project Settings
To update the Vungle SDK, replace the LiftoffSDK.Win32.dll located in Assets/Liftoff/Plugins/x86_64.
Step 3. Build the Plugin Bridge
You can make adjustments to the bridge by editing the code in https://github.com/Vungle/Unity-Plugin/tree/master/LiftoffUnityWindowsPlugin/plugin/LiftoffUnityBridge, then replace the LiftoffUnityBridge.dll located in Assets/Liftoff/Plugins/x86_64.
Step 4. Register Callbacks
The Unity Plugin will provide information about initialization, ad load, and playback status via callbacks. Register the callbacks prior to initialization.
LiftoffWindows.OnInitialized += () = LogUI("[Liftoff] Initialized.");
LiftoffWindows.OnInitializationFailed += (c, m) = LogUI($"[Liftoff] Init failed {c}: {m}");
LiftoffWindows.OnAdLoaded += p = LogUI($"[Liftoff] Loaded: {p}.");
LiftoffWindows.OnAdLoadFailed += (p, c, m) = LogUI($"[Liftoff] Load fail {p}: {c} {m}");
LiftoffWindows.OnAdStart += (p, eid) = LogUI($"[Liftoff] Start {p} eid={eid}");
LiftoffWindows.OnAdEnd += p = LogUI($"[Liftoff] End {p}");
LiftoffWindows.OnAdPlayFailed += (p, c, m) = LogUI($"[Liftoff] Play fail {p}: {c} {m}");
LiftoffWindows.OnAdRewarded += p = LogUI($"[Liftoff] Rewarded {p}");
LiftoffWindows.OnAdClick += p = LogUI($"[Liftoff] Click {p}");
LiftoffWindows.OnDiagnostic += (level, sender, msg) = LogUI($"{DateTime.Now:HH:mm:ss} [{sender}] {msg}");Step 5. Initialize the SDK
You can make the initialization API call on any thread. Obtain a window handle and provide it to the initialize process. This handle will be used for the ad presentation as well. Ensure that WebView2 is installed on the device.
IntPtr hwnd = IntPtr.Zero;
try { hwnd = GetActiveWindow(); } catch (Exception e) { LogUI($"[Liftoff] GetActiveWindow failed: {e.Message}"); }
if (hwnd == IntPtr.Zero)
{
try { hwnd = System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle; }
catch (Exception e) { LogUI($"[Liftoff] MainWindowHandle failed: {e.Message}"); }
}
if (!LiftoffWindows.IsWebView2Available())
LogUI("[Liftoff] WebView2 Runtime not detected (install Evergreen).");
LogUI("[Liftoff] Initializing...");
LiftoffWindows.Initialize(appId, hwnd);Step 6. Add Code to Load and Play Ads
Load an Ad
The LoadAd API requires the placement ID. Be sure to register to the load callbacks to know if the load was successful or not.
LiftoffWindows.LoadAd(placement);Play an Ad
The PlayAd API requires the placement ID. The ad will be presented on the window handle provided in the initialization step. Ensure that this API is called after the OnAdLoaded is triggered for your wanted placement ID from the LoadAd call.
This API must be called on the main thread.
LiftoffWindows.PlayAd(placement);