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

Icon ads

fan-k-manabe edited this page Aug 25, 2016 · 4 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 Icon Ads(*Android only)

Procedure is as follows.

  1. Add NendAdIcon 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/NendAdIcon.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 icon ad spaces.

Name GameObject such as NendAdIcon1, NendAdIcon2 so that they are unique.

image

“IF” in NendAdIcon class.

NendAdIcon class provides the following IF's.

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

NendAdIcon and other related classes can be referred only when Build target is Android.
If your app supports both Android and iOS and you would like to use IF in NendAdIcon class, please surround implementation area by #UNITY_ANDROID platform macro as an example below shows.

using NendUnityPlugin.AD;
...

#if UNITY_ANDROID
    NendAdIcon iconAd = ...;

    ...

    iconAd.Hide ();

    ...

    icon.Layout (new NendAdIconLayoutBuilder ().Orientation (Orientation.HORIZONTAL));

    ...

    icon.AdLoaded += ...;
#endif

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

Details of Items

Account

Input Android account data.

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 icon ad after a schene starts up. Use this function if you want to show icon ads only when you want to.

Item Explanation
ON Icon ads appear after a scene starts up.
OFF Icon ads do not appear after a scene starts up.
Orientation

Set to which the direction you want to place icon ads.

Item Explanation
HORIZONTAL Set icon ads horizontal
VERTICAL Set icon ads vertical
UNSPECIFIED Set icon ads without allighnment.
Gravity

Set the position of icon ads by height and width.Default setting is upper left.
This is effective only when you chose HORIZONTAL or VERTICAL in Orientation field.

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 icon ads(dip).
This is effective only when you chose HORIZONTAL or VERTICAL in Orientation field.
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.
Icon
Item Explanation
Size Input the number of icon ads. (Maximum 6)

The following settings are set for each icon ads(Element 0〜).

Tag

Input tags(number) to identify icon ads.

Use this function to set layout for each icon ad through program.
The value of tags for each icon ad must be unique.
If you do not set layout through program, this field does not need to be filled.

Please check API reference.

Size

Input the size of icon ads(dip).

Space Enabled

Set this field if you need margin for icon ads.

Item Explanation
ON Show margin for icon ads.
OFF Do not show margin for icon ads.
Title Visible

Control how icon ads title appear.

Item Explanation
ON Show icon ads title.
OFF Do not show icon ads title.
Title Color

Set color of icon ads title. If nothing is set, it becomes black.
Input #rrggbb format (e.g. #FFFFFF)

Gravity

Set the position of icon ads by height and width.Default setting is upper left.
This is effective only when you chose UNSPECIFIED in Orientation field.

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 icon ads(dip).
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. 4 icon ads set to the horizontal bottom conseqtively.

image

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

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

#if UNITY_ANDROID
    NendAdIcon icon = ...;
    icon.AdLoaded += OnFinishLoadIconAd;
    icon.AdReceived += OnReceiveIconAd;
    icon.AdFailedToReceive += OnFailToReceiveIconAd;
    icon.AdClicked += OnClickIconAd;
    icon.InformationClicked += OnClickInformation;
#endif

...

#if UNITY_ANDROID
    public void OnFinishLoadIconAd (object sender, EventArgs args)
    {
        UnityEngine.Debug.Log ("Ad loading is complete.
    }

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

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

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

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

Verification

Clone this wiki locally