Unity Package Integration Guide
This document provides comprehensive instructions for integrating our Unity Package into your Unity project. It specifically addresses the dependency on the External Dependency Manager for Unity and outlines the steps to implement various ad formats, including HTML banner, banner video, interstitial, video interstitial, multi-format interstitial, and rewarded ads.
Prerequisites
Before you begin, ensure you have the following:
- Unity 2022.3 or later
- The Unity Package (File)
- An active internet connection for dependency resolution
- Account Id and config id from Nexverse publisher dashboard. Refer to the App Onboarding Guide for detailed steps to generate these identifiers.
External Dependency Manager (EDM4U) Installation
Our Unity Package relies on the External Dependency Manager for Unity (EDM4U) to resolve its external dependencies.
- Download EDM4U: If you do not have EDM4U installed, you can download it from its official GitHub repository: https://github.com/googlesamples/unity-jar-resolver/releases
- Import EDM4U:
- Open your Unity project.
- Navigate to Assets > Import Package > Custom Package…
- Select the downloaded EDM4U .unitypackage file and click Open.
- Ensure all components are selected and click Import.
Importing the Unity Package
Once EDM4U is successfully installed, you can import our Unity Package.
- Import Unity Package:
- In your Unity project, navigate to Assets > Import Package > Custom Package…
- Select the Unity Package file (File) and click Open.
- Ensure all components are selected and click Import.
Resolving Dependencies
After importing our Unity Package, EDM4U will automatically attempt to resolve its dependencies.
- Automatic Resolution: EDM4U should automatically trigger a dependency resolution process upon import. You will typically see a progress bar indicating the download of necessary libraries.
- Manual Resolution (if needed): If dependencies are not resolved automatically, you can manually trigger the resolution:
- Go to Assets > External Dependency Manager > Android Resolver > Resolve.
- (For iOS) Go to Assets > External Dependency Manager > iOS Resolver > Resolve.
Verifying Installation
To ensure the Unity Package is correctly integrated:
- Check the Assets folder for the Nexverse folder.
- Verify that the required .jar or .framework files have been added to your project’s Plugins folder, typically under Assets/Plugins/Android or Assets/Plugins/iOS. If auto resolution is not enabled then you can skip this step.
SDK Initialization
SDK should be initialized before ad call.
private void Start()
{
//other code
//Before calling any function you must initialize the plugin.
NexverseUnityPlugin.Initialize();
NexverseSdk.ShareGeoLocation(true);
//Uncomment the following line if you want to support coppa
//NexverseSdk.SetSubjectToCoppa(true);
// NexverseSdk.SetSubjectToGdpr(gdprConsent);
// NexverseSdk.SetGdprConsentString(gdprConsentString);
// NexverseSdk.SetGlobalOrtbConfig(targetingParams);
//if you want to test the integration, you can use the test mode
// NexverseSdk.SetTestMode(true);
//Initialize the SDK, this should be called once.
NexverseSdk.Init(accountId); //replace the account id
}
Test mode
Enables or disables Test Mode for the SDK network responses. This is recommended while the app is in development mode.
//Set the test mode to true
NexverseSdk.SetTestMode(true);
Note: Please don’t forget to set it to false before pushing the app to live.
Global OpenRTB Configuration
Sets the global OpenRTB (oRTB) configuration parameters used for Ad requests.
//Set OpenRTB config
NexverseSdk.SetGlobalOrtbConfig(targetingParams);
targetingParams: JSON string containing key-value pairs for targeting (e.g., user segments, interests, demographics).
Recommended Usage: Call this once during initialization to set global parameters. Can also be updated later if targeting information changes (e.g., after user login).
GDPR Consent
Specifies whether the user is subject to GDPR regulations. Parameters: gdprConsent: Pass true if GDPR applies to the user, otherwise false.
Recommended Usage: Should be called at initialization, based on the user’s region or CMP determination. Must be set before passing GDPR consent string.
//Set the GDPR consent
NexverseSdk.SetSubjectToGdpr(true);
Configures the SDK with the user’s GDPR consent string. This is typically obtained from a CMP (Consent Management Platform).
//GDPR consent string
NexverseSdk.SetGdprConsentString(gdprConsentString);
Parameters: gdprConsentString: The IAB-compliant GDPR consent string representing the user’s preferences.
Recommended Usage: Call this method before requesting Ads to ensure consent is respected. Update whenever a new consent string is obtained from the CMP.
COPPA Settings
Specifies whether the user is subject to COPPA (Children’s Online Privacy Protection Act) compliance.
//Update the COPPA setting for your app
NexverseSdk.SetSubjectToCoppa(true);
Parameter: Pass true if COPPA applies to the user, otherwise false.
Recommended Usage: Call during SDK initialization if your app is directed towards children under 13 or needs COPPA compliance. Once set, should not be changed during the session.
Location And Permission Configuration
To improve Ad targeting and provide a better Ad experience, Sets the user’s consent for sharing location information if the app wants to trigger requesting location permission as per their use case.
//If you want to share the user's location set it to true otherwise false
NexverseSdk.ShareGeoLocation(shouldShare);
If location permission (ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION) is already granted:
- The SDK will use the device’s location information when making requests (if shouldShare = true).
- If permission is not granted, SDK will request for permission when shouldShare=true.
- If shouldShare = false, the SDK will stop using location data.
SDK Callbacks:
INexverseCallbacks: (Recommended) This listener has support for all the ad types. We recommend adding it in Start.
public class NexverseDemo : MonoBehaviour, INexverseCallbacks
{
private void Start()
{
//other code
//Before calling any function you must initialize the plugin.
NexverseUnityPlugin.Initialize();
//Sdk callback
NexverseCallbacks.Instance.SetCallbacks(this);
//Initialize the SDK, this should be called once.
NexverseSdk.Init(accountId); //replace the account id
}
public void OnSdkInitialized() => Debug.Log("[Nexverse] SDK initialized successfully.");
public void OnSdkInitializedWithWarning(string warning) => Debug.Log("[Nexverse] SDK initialized with warning: "+warning);
public void OnSdkFailed(string error) => Debug.Log("[Nexverse] SDK initialized failed: "+error);
// Banner
public void OnBannerLoaded() => Debug.Log("[Nexverse] Banner loaded" );
public void OnBannerDisplayed() => Debug.Log("[Nexverse] Banner displayed" );
public void OnBannerClicked() => Debug.Log("[Nexverse] Banner clicked" );
public void OnBannerClosed() => Debug.Log("[Nexverse] Banner closed" );
public void OnBannerFailed(string error) => Debug.LogWarning("[Nexverse] Banner failed: " + error);
public void OnBannerDestroyed() => Debug.Log("[Nexverse] Banner destroyed");
// Banner video
public void BannerVideoCompleted() => Debug.Log("[Nexverse] Banner video completed" );
public void BannerVideoPaused() => Debug.Log("[Nexverse] Banner video paused" );
public void BannerVideoResumed() => Debug.Log("[Nexverse] Banner video resumed" );
public void BannerVideoUnMuted() => Debug.Log("[Nexverse] Banner video unmuted" );
public void BannerVideoMuted() => Debug.LogWarning("[Nexverse] Banner video muted");
// Interstitial
public void OnInterstitialLoaded()
{
Debug.Log("[Nexverse] Interstitial loaded" );
NexverseSdk.ShowInterstitial();
}
public void OnInterstitialDisplayed()=> Debug.Log("[Nexverse] Interstitial displayed" );
public void OnInterstitialFailed(string error) => Debug.LogWarning("[Nexverse] Interstitial failed: " + error);
public void OnInterstitialShowError(string errorMessage) => Debug.LogWarning("[Nexverse] Interstitial show error: " + errorMessage);
public void OnInterstitialClicked() => Debug.Log("[Nexverse] Interstitial clicked" );
public void OnInterstitialClosed() => Debug.Log("[Nexverse] Interstitial closed" );
//rewarded ad
public void RewardAdLoaded()
{
Debug.Log("[Nexverse] rewarded loaded" );
NexverseSdk.ShowRewarded();
}
public void RewardAdDisplayed()=> Debug.Log("[Nexverse] Reward displayed" );
public void RewardAdFailed(string error) => Debug.LogWarning("[Nexverse] Reward failed: " + error);
public void RewardAdClicked() => Debug.Log("[Nexverse] Reward clicked" );
public void RewardAdClosed() => Debug.Log("[Nexverse] Reward closed" );
public void RewardAdReward(Reward reward) => Debug.Log("[Nexverse] Reward data: "+reward?.count);
public void RewardAdShowError(string errorMsg) => Debug.Log("[Nexverse] Reward error: "+errorMsg );
//other codes
}
You should proceed with the ads if SDK initialization was successful.
ISdkInitCallback:(Optional) If you don’t want to use INexverseCallbacks then you can use the individual callback for each ad type and initialization. For SDK initialization you can use the ISdkInitCallback interface.
public class NexverseDemo : MonoBehaviour, ISdkInitCallback
{
private void Start()
{
//other code
//Before calling any function you must initialize the plugin.
NexverseUnityPlugin.Initialize();
//Sdk init callbacks
NexverseCallbacks.Instance.SetInitCallbacks(this);
//Initialize the SDK, this should be called once.
NexverseSdk.Init(accountId); //replace the account id
}
public void OnSdkInitialized()
{
Debug.Log("[Nexverse] SDK initialized successfully.");
}
public void OnSdkInitializedWithWarning(string warning)
{
Debug.Log("[Nexverse] SDK initialized with warning: "+warning);
}
public void OnSdkFailed(string error)
{
Debug.Log("[Nexverse] SDK initialized failed: "+error);
}
//other codes
}
You should proceed with the ads if SDK initialization was successful.
Ad Format Integration
Our Unity Package supports the following ad formats:
1: Interstitial
2: Rewarded video
3: Banner
Interstitial Ad
Multi-Format Interstitial Ad
The multi-format interstitial automatically adapts to display the best available ad type (image, video, etc.).
To display an interstitial ad:
Call the interstitial ad loading method at an appropriate point in your application flow (e.g., between level transitions).
//Load and interstitial ad
NexverseSdk.LoadInterstitial(configIdAndroid, configIdIos); //replace the configId
Present the interstitial ad when it’s ready.
//Show the interstitial ad
if(NexverseSdk.IsInterstitialReady())
NexverseSdk.ShowInterstitial();
IInterstitialCallback:(Optional) You can skip this if you have already added INexverseCallbacks already.
You need to add the IInterstitialCallback interface to your MonoBehaviour.
public class NexverseDemo : MonoBehaviour, ISdkInitCallback, IInterstitialCallback
{
private void Start()
{
//other code
//Before calling any function you must initialize the plugin.
NexverseUnityPlugin.Initialize();
//Sdk init callbacks
NexverseCallbacks.Instance.SetInitCallbacks(this);
//Initialize the SDK, this should be called once.
NexverseSdk.Init(accountId); //replace the account id
//interstitial ad callbacks
NexverseCallbacks.Instance.SetInterstitialCallbacks(this);
//Load an interstitial ad, replace the config ids
NexverseSdk.LoadInterstitial(configIdAndroid, configIdIos);
}
//other codes
// Interstitial callbacks
public void OnInterstitialLoaded()
{
Debug.Log("[Nexverse] Interstitial loaded: " );
//here you can show the interstitial.
NexverseSdk.ShowInterstitial();
}
public void OnInterstitialDisplayed()
{
Debug.Log("[Nexverse] Interstitial displayed: " );
}
public void OnInterstitialFailed(string error){
{
Debug.LogWarning("[Nexverse] Interstitial failed: " + error);
}
public void OnInterstitialShowError(string errorMessage)
{
Debug.LogWarning("[Nexverse] Interstitial show error: " + errorMessage);
}
public void OnInterstitialClicked()
{
Debug.Log("[Nexverse] Interstitial clicked: " );
}
public void OnInterstitialClosed()
{
Debug.Log("[Nexverse] Interstitial closed: " );
}
}
Video Interstitial Ad
If you want to restrict the interstitial ad to serve only video ad you can restrict it by following code.
For video interstitial ads, follow a similar pattern to standard interstitials:
- Load the video interstitial at a suitable time.
// Load the video interstitial ad, replace the config id
NexverseSdk.LoadInterstitial(configIdAndroid, configIdIos, NexverseSdk.InterstitialAdFormat.Video);
- Show the video interstitial when it’s prepared.
//Show the interstitial ad
if(NexverseSdk.IsInterstitialReady())
NexverseSdk.ShowInterstitial();
Banner/HTML Interstitial Ad
If you want to restrict the interstitial ad to serve only html/image ads you can restrict it by following code.
For html interstitial ads, follow a similar pattern to standard interstitials:
- Load the htm/banner interstitial at a suitable time.
// Load the video interstitial ad, replace the config id
NexverseSdk.LoadInterstitial(configIdAndroid, configIdIos, NexverseSdk.InterstitialAdFormat.Banner);
- Show the html/banner interstitial when it’s prepared.
//Show the interstitial ad
if(NexverseSdk.IsInterstitialReady())
NexverseSdk.ShowInterstitial();
Rewarded Ad
Rewarded Ads are a powerful monetization tool that provides value to both users and developers. They allow users to earn in-app rewards (such as virtual currency, extra lives, or premium content) in exchange for watching a video Ad. This opt-in format typically sees high engagement rates and user satisfaction.
Note Reward will be received only if reward is set inside the dashboard while configuring the Ad.
Key benefits:
- Higher user engagement due to opt-in nature
- Better user experience through value exchange
- Increased retention through reward mechanics
- Higher eCPMs compared to other Ad formats
To display an rewarded ad:
Call the interstitial ad loading method at an appropriate point in your application flow (e.g., between level transitions).
//Load a rewarded ad, replace the configId
NexverseSdk.LoadRewarded(configIdAndroid, configIdIos);
Present the interstitial ad when it’s ready.
//Show the rewarded ad
if(NexverseSdk.IsRewardedReady())
NexverseSdk.ShowRewarded();
IRewardedCallback:(Optional) You can skip this if you have already added INexverseCallbacks already.
You need to add the IRewardedCallback interface to your MonoBehaviour.
public class NexverseDemo : MonoBehaviour, ISdkInitCallback, IInterstitialCallback, IRewardedCallback
{
private void Start()
{
//other code
//Before calling any function you must initialize the plugin.
NexverseUnityPlugin.Initialize();
//Sdk init callbacks
NexverseCallbacks.Instance.SetInitCallbacks(this);
//Initialize the SDK, this should be called once.
NexverseSdk.Init(accountId); //replace the account id
//rewarded ad callbacks
NexverseCallbacks.Instance.SetRewardedCallbacks(this);
//Load a rewarded ad, replace the configId
NexverseSdk.LoadRewarded(configIdAndroid, configIdIos);
}
//other codes
public void RewardAdLoaded()
{
Debug.Log("[Nexverse] rewarded loaded: " );
//You can show the ad here
NexverseSdk.ShowRewarded();
}
public void RewardAdDisplayed()
{
Debug.Log("[Nexverse] Reward displayed: " );
}
public void RewardAdFailed(string error)
{
Debug.LogWarning("[Nexverse] Reward failed: " + error);
}
public void RewardAdClicked()
{
Debug.Log("[Nexverse] Reward clicked: " );
}
public void RewardAdClosed(){
Debug.Log("[Nexverse] Reward closed: " );
}
public void RewardAdReward()
{
Debug.Log("[Nexverse] Reward data: " );
}
public void RewardAdShowError(string errorMsg)
{
Debug.Log("[Nexverse] Reward error: "+errorMsg );
}
}
Banner Ads
Banner Ads are rectangular display units that occupy a portion of your app’s layout. The SDK supports both HTML and Video banner formats. These Ads can be placed at various positions within your app’s interface and can be configured to refresh automatically at specified intervals.
The following table lists the standard banner sizes.
| Size in dp (WxH) | Description | Availability | Supported Type |
|---|---|---|---|
| 300x50 | Banner | Phones and tablets | Banner |
| 320x50 | Banner | Phones and tablets | Banner |
| 320x100 | Large banner. | Phones and tablets | Banner |
| 300x250 | IAB medium rectangle | Phones and tablets | Banner, Video |
| 468x60 | IAB full-size banner | Tablets | Banner |
| 728x90 | IAB leaderboard | Tablets | Banner |
HTML Banner
HTML banners are the most common type of banner ads. They can display static images, animated content, or interactive rich media.
//replace the config ids
NexverseSdk.CreateBanner(configIdAndroid, configIdIos, AdSize.Banner320X50, BannerPlacement.Top, autoRefreshSec: 30, video: false);
| Parameter | Description | Default value | Required? |
|---|---|---|---|
| configIdAndroid | Android placement id | Yes | |
| configIdIos | iOS placement id | Yes | |
| adSize | One of AdSize | 320x50 | Yes |
| placement | Banner placement | Top | No |
| autoRefreshSec | Refresh timer in seconds | 60 | No |
| video | If you want to enable video. | false | No |
IBannerCallback: (Optional) You can skip this if you have already added INexverseCallbacks already.
You need to add the IBannerCallback interface to your MonoBehaviour.
public class NexverseDemo : MonoBehaviour, ISdkInitCallback, IInterstitialCallback, IBannerCallback
{
private void Start()
{
//other code
//Before calling any function you must initialize the plugin.
NexverseUnityPlugin.Initialize();
//Sdk init callbacks
NexverseCallbacks.Instance.SetInitCallbacks(this);
//Initialize the SDK, this should be called once.
NexverseSdk.Init(accountId); //replace the account id
//Interstitial ad callbacks
NexverseCallbacks.Instance.SetInterstitialCallbacks(this);
//Banner ad callbacks
NexverseCallbacks.Instance.SetBannerCallbacks(this);
//Replace the config ids
NexverseSdk.CreateBanner(configIdAndroid, configIdIos, AdSize.Banner320X50, BannerPlacement.Top, autoRefreshSec: 30, video: false);
}
//other codes
public void OnBannerLoaded()
{
Debug.Log("[Nexverse] Banner loaded: " );
}
public void OnBannerDisplayed()
{
Debug.Log("[Nexverse] Banner displayed: " );
}
public void OnBannerClicked()
{
Debug.Log("[Nexverse] Banner clicked: " );
}
public void OnBannerClosed()
{
Debug.Log("[Nexverse] Banner closed: " );
}
public void OnBannerFailed(string error)
{
Debug.LogWarning("[Nexverse] Banner failed: " + error);
}
public void OnBannerDestroyed()
{
Debug.Log("[Nexverse] Banner destroyed");
}
}
Banner Video
Video banner Ads provide an engaging way to monetize your app through video content. These Ads play video content directly within a banner format.
To integrate a banner video ad:
// Load and show banner video ad
NexverseSdk.CreateBanner(configIdAndroid, configIdIos, AdSize.Video, BannerPlacement.Bottom, autoRefreshSec: 30, true);
Note: Video banner is only available in 300x250 sizes as of now.
IBannerVideoCallback:(Optional) You can skip this if you have already added INexverseCallbacks already.
You need to add the IBannerVideoCallback interface to your MonoBehaviour.
public class NexverseDemo : MonoBehaviour, ISdkInitCallback, IInterstitialCallback, IBannerCallback, IBannerVideoCallback
{
private void Start()
{
//other code
//Before calling any function you must initialize the plugin.
NexverseUnityPlugin.Initialize();
//Sdk init callbacks
NexverseCallbacks.Instance.SetInitCallbacks(this);
//Initialize the SDK, this should be called once.
NexverseSdk.Init(accountId); //replace the account id
//banner ad callbacks
NexverseCallbacks.Instance.SetBannerCallbacks(this);
NexverseCallbacks.Instance.SetBannerVideoCallbacks(this);
// Load and show banner video ad
NexverseSdk.CreateBanner(configIdAndroid, configIdIos, AdSize.Video, BannerPlacement.Bottom, autoRefreshSec: 30, true);
}
//other codes
public void BannerVideoCompleted()
{
Debug.Log("[Nexverse] Banner video completed: " );
}
public void BannerVideoPaused()
{
Debug.Log("[Nexverse] Banner video paused: " );
}
public void BannerVideoResumed()
{
Debug.Log("[Nexverse] Banner video resumed: " );
}
public void BannerVideoUnMuted()
{
Debug.Log("[Nexverse] Banner video unmuted: " );
}
public void BannerVideoMuted()
{
Debug.LogWarning("[Nexverse] Banner video muted: ");
}
}
Remove Banner
You can remove the active banner by using the following:
//Remove the active banner on screen
NexverseSdk.DestroyBanner();
Limitation
Currently you can add only one banner at a time. Multiple banners are not supported. If you need this you can reach out to the support team.
Support
For any issues during integration, please contact at support@nexverse.ai or visit our support page Nexverse.