Skip to content

Unity Plugin Banner Integration

Eros edited this page Feb 12, 2021 · 7 revisions

Creating the Banner

The HyBidAdView should be created inside a script which is linked to a GameObject. It must be created using the HyBidAdViewFactory createHyBidAdView() method which created a banner based on the platform that the application is being built for.

public static HyBidAdView createHyBidAdView(MonoBehaviour parent);

A sample of this instantiation is the following:

HyBidAdView banner = HyBidAdViewFactory.createHyBidAdView(this);

In the previous sample this is an object which inherits from MonoBehaviour so it’s linked to a GameObject.

After creating the Banner you must set the appToken and placement properties:

banner.appToken =App Token obtained from PubNative dashboard”;
banner.placement = “Placement Name configured and obtained from the PubNative Dashboard”;

You should implement the IAdViewListener() for HyBidAdView.

public interface IAdViewListener
{
    void OnAdLoaded ();

    void OnAdLoadFailed (Exception error);

    void OnAdImpression ();

    void OnAdClick ();
} 

Adding an ** AdViewListener** to the ** HyBidAdView** is mandatory since it will send callbacks when the ad was loaded or failed. After the ad is loaded then it can be displayed.

Here’s an implementation sample:

banner.AdViewListener = AD_VIEW_LISTENER_INSTANCE;

Loading the Banner

To load the Banner you should use the Load(position) method. It can be displayed in two positions on the screen: TOP(1) or BOTTOM(2). This method must be invoked in the following way:

banner.Load(1); //Show banner on Top of the screen
banner.Load(2); //Show banner on the Bottom of the screen

The result of this method will be received in the ** IAdViewListener** callbacks.

Here is a complete code sample about how you can integrate the HyBidAdView.


-> Unity Plugin Interstitial Integration

Clone this wiki locally