Skip to content
This repository has been archived by the owner on Apr 5, 2024. It is now read-only.

Banner ads

fan-w-suzuki edited this page Jul 10, 2018 · 5 revisions

Preparation

If you have not created ad spaces or downloaded SDK, please refer to the link below.

SDK Implementation

If you have not imported Unity package into project, please follow the link below.


How to show Banner Ads

Procedure is as follows.

  1. Add NendAdBanner into "Scene"
  2. Setting by Inspector
  3. Event Handling(optional)

Choose “GameObject” > “CreateEmpty”. Create empty GameObject. image

Change the name of GameObject you created just now to unique one.
Add “Assets/NendAd/Scripts/AD/NendAdBanner.cs” to GameObject. image

If you create multiple ad spaces, plelase repeat the same procedure. GameObject names have to be unique.

e.g. in case you create 2 banner ad spaces.

Name GameObject such as NendAdBanner1, NendAdBanner2 so that they are unique. image

IF in NendAdBanner class.

NendAdBanner class provides the following IF's.

  1. Show/Hide Ads
  2. Pause/Restart Ad rotation
  3. Layout setting(added at v1.2.0)

e.g. Pause Ad refresh and hide it when scene moves to another scene.

using UnityEngine.SceneManagement;
using NendUnityPlugin.AD;

void GoToOtherScene ()
{
    var banner = gameObject.GetComponent <NendAdBanner> ();
    banner.Pause ();
    banner.Hide ();

    SceneManager.LoadScene ("OtherScene");
}

Next, you set ad space information, placement etc. on Inspector. Inspector

Details of Items

Account

Account infromation for each OS. OS that is not included in “Build” does not require input.

Item Explanation
Api Key Input the apiKey issued provided from management screen.
Spot Id Input the spotId provided from management screen.
Automatic Display

You can set up if you want to show a banner ad after a schene starts up.
Use this function if you want to show banner ads only when you want to.

Item Explanation
ON Banner ads appear after a scene starts up.
OFF Banner ads do not appear after a scene starts up.
Adjust Size (added at v1.3.0)

This function allows you to auto-adjust your ad sizes, depending ot the screen sizes.
Please see nendSDK-iOS and nendSDK-Android manual for details.

Item Explanation
ON Auto-adjust is on.
OFF Auto-adjust is off.
Size

This function allows you to set banner ad size.(iOS only)

Item Explanation
Size_320×50 Show ads in 320×50 size.
Size_320×100 Show ads in 320×100 size.
Size_300×100 Show ads in 300×100 size.
Size_300×250 Show ads in 300×250 size.
Size_728×90 Show ads in 728×90 size.
Background Color (added at v1.3.5)

Banner ads' backgroud color can be set by this function.

Gravity

Set the position of banner ads by height and width. Default setting is upper left.

Item Explanation
Size Input number for setting.
LEFT Show ads to the left.
TOP Show ads to the top.
RIGHT Show ads to the right.
BOTTOM Show ads to the bottom.
CENTER_VERTICAL Show ads to the vertical center.
CENTER_HORIZONTAL Show ads to the horizontal center.
Margin

Set margins of banner ads.
Unit for Android is dip and for iOS is pt.
If you set Gravity, margin is counted from the point where Gravity is set.

Item Explanation
Left Set left margin.
Top Set top margin.
Right Set right margin.
Bottom Set bottom margin.

e.g. 320×50 banner ad set to the horizontal bottom.

image

You can receive event information such as ad-load, click etc. by adding delegation method to NendAdBanner EventHandler.

using NendUnityPlugin.AD;
using NendUnityPlugin.Common;
...

NendAdBanner banner = ...;
banner.AdLoaded += OnFinishLoadBannerAd;
banner.AdReceived += OnReceiveBannerAd;
banner.AdFailedToReceive += OnFailToReceiveBannerAd;
banner.AdClicked += OnClickBannerAd;
banner.AdBacked += OnDismissScreen;
banner.InformationClicked += OnClickInformation;
...

public void OnFinishLoadBannerAd (object sender, EventArgs args) {
    UnityEngine.Debug.Log ("Ad load is completed.");
}

public void OnClickBannerAd (object sender, EventArgs args) {
    UnityEngine.Debug.Log ("Ad is clicked");
}

public void OnReceiveBannerAd (object sender, EventArgs args) {
    UnityEngine.Debug.Log ("Successfully received ads.");
}

public void OnFailToReceiveBannerAd (object sender, NendAdErrorEventArgs args) {
    UnityEngine.Debug.Log ("Failed to receive ads.Error message: " + args.Message);
}

public void OnDismissScreen (object sender, EventArgs args) {
    UnityEngine.Debug.Log ("Ads recored on the screen.");
}

public void OnClickInformation(object sender, EventArgs args) {
    UnityEngine.Debug.Log ("Information button is clicked and the user moved to the opt-out page.");
}

Verification

Clone this wiki locally