-
Notifications
You must be signed in to change notification settings - Fork 5
Icon ads
If you have not created ad spaces or downloaded SDK, please refer to the link below.
If you have not imported Unity package into project, please follow the link below.
Procedure is as follows.
Choose “GameObject” > “CreateEmpty”. Create empty GameObject
.
Change the name of GameObject
you created just now to unique one. Add “Assets/NendAd/Scripts/AD/NendAdIcon.cs” to GameObject
.
If you create multiple ad spaces, plelase repeat the same procedure. GameObject
names have to be unique.
Name GameObject
such as NendAdIcon1, NendAdIcon2 so that they are unique.
NendAdIcon
class provides the following IF's.
- Show/Hide Ads
- Pause/Restart Ad rotation
- 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.
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. |
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. |
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. |
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. |
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. |
Item | Explanation |
---|---|
Size | Input the number of icon ads. (Maximum 6) |
The following settings are set for each icon ads(Element 0〜).
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.
Input the size of icon ads(dip).
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. |
Control how icon ads title appear.
Item | Explanation |
---|---|
ON | Show icon ads title. |
OFF | Do not show icon ads title. |
Set color of icon ads title. If nothing is set, it becomes black.
Input #rrggbb format (e.g. #FFFFFF)
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. |
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. |
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