-
Notifications
You must be signed in to change notification settings - Fork 5
Native 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.
-
Add
GameObject
intoCanvas
which is located within Scene. Set ad position/size by usingRectTransform
of Inspector. -
Add
NendAdNativeView
toGameObject
created at step1 above. -
Add Text or RawImage of ads to
GameObject
created at step 1 above to set position/size. -
Connect
Text
orRawImage
toNendAdNativeView
ad items below on inspector.
Item | Explanation |
---|---|
Pr Text |
Text which displays Advertising Explicitly |
Short Text |
Text which displays ad header |
Long Text |
Text which displays ad text |
Promotion Name Text |
Text which displays promotion name |
Promotion Url Text |
Text which displays promotion URL |
Action Button Text |
Text which displays action button text |
Ad Image |
RawImage which displays ad images |
Logo Image |
RawImage which show logo images |
Each item has to be displayed under the restriction below.
- Advertising Explicitly must be displayed.
- Either ad header, ad text or promotion name has to be displayed.
- If ad space includes image, ad image has to be displayed.
- Ad expansion/shrink ratio must be within 30% ~150%.
- Ad image clipping must be within 6% both horizontally and vertically.
- Clipping logo image is not allowed.
The following items can be set.
Item | Explanation | type | Supplement |
---|---|---|---|
View Tag | The tag which recognize ad view | int |
|
Render When Loaded | Choose if ad information is described right after ad load. | bool |
Use this function if you want to display ads at specified timing |
Render When Activated | Choose if you draw ad information when GameObject becomes active |
bool |
Use this function if you want to display ads at specified timing |
Advertising Explicitly | Text which is displayed for Advertising Explicitly | AdvertisingExplicitly |
|
Ad Shown | Event which is notified when ad is displayed | UnityEvent<NendAdNativeView> |
|
Ad Clicked | Event which is notified when ad is clicked. | UnityEvent<NendAdNativeView> |
The following messages will be shown.
Items | Message |
---|---|
PR | PR |
Sponsored | Sponsored |
AD | 広告 |
Promotion | プロモーション |
You can use the following IF from app side.
Draw ad which is already loaded. If ad is not loaded, it returns false
.
get/set tags.
Acquire the status if ad is loaded or not.
using UnityEngine;
using NendUnityPlugin.AD.Native;
...
public class YourScene : MonoBehaviour {
// On the assumption that these are connected on Inspector
public NendAdNativeView nativeAdView;
private void DoSomething () {
if (nativeAdView.Loaded) {
nativeAdView.RenderAd ();
}
}
}
-
Add
NendAdNative
toGameObject
which you selected and which is within scene which displays ads. -
Register
NendAdNativeView
which displays ad ID and Ads onNendAdNative
Inspector.
Item | Explanation | Type | Supplement |
---|---|---|---|
Account | apiKey and spotID of Android and iOS | apiKey:string spotID:int
|
OS which is not included in build does not need this setting. |
Load When Activated | If NendAdNative loads ads when GameObject becomes active. |
bool |
Load all ads registered on NendAdNativeView
|
Enable Auto Reload | If ad is reloaded automatically | bool |
Reload all ads redistered on NendAdNativeView
|
Reload Interval | Auto reload interval(millisecond) | double |
Must be 30 seconds or more |
Views | View which displays native ads | NendAdNativeView |
Multiple settings are allowed |
Ad Loaded | Event which is notified when ad is loaded | UnityEvent<NendAdNativeView> |
|
Ad Failed To Receive | Event which is notified when ad load failed. | UnityEvent<NendAdNativeView, int, string> |
The second argument is error code and the third argument is error message. The content of error code is as follows. 332: The number of ad display exceeded the maximum cap. 340: Request failed(communication error etc.) 341: inside SDK error 342: unsupported image format |
type | Ad space type | NativeAdType |
Use this function to check ad display on Editor. It is not used when actual device works. |
If Load When Activated
is true
and Render When Loaded
of registered NendAdNativeView
is true
, native ad load and display is done automatically when GameObject
with NendAdNative
is read by scene.
Item | Ad type |
---|---|
SmallSquare | With ad image(80x80) |
LargeWide | With adimage(300x180) |
TextOnly | No ad image |
You can use the following IF from app side.
Load all registered ads in NendAdNativeView.
Load NendAdNativeView
ads with specified tags
Acquire the list of registered NendAdNativeView
Register NendAdNativeView
which displays ads.
Delete registered NendAdNativeView
.
Reload ads automatically by specified interval (millisecond).
Reload interval has to be 30 seconds or more.
Stop auto ad reload.
using NendUnityPlugin.AD.Native;
...
// Acquiring instance from GameObject with NendAdNative.
var nativeAd = gameObject.GetComponet <NendAdNative> ();
foreach (var nativeAdView in nativeAd.Views) {
if (!nativeAdView.Loaded) {
nativeAd.LoadAd (nativeAdView.ViewTag);
}
}
using UnityEngine;
using NendUnityPlugin.AD.Native;
...
public class YourScene : MonoBehaviour {
// On the assumption that these are connected on Inspector
public NendAdNative nativeAd;
void OnApplicationPause (bool pauseStatus) {
if (pauseStatus) {
nativeAd.DisableAutoReload ();
} else {
// e.g. Reload every 1 min
nativeAd.EnableAutoReload (60000.0);
}
}
}
- Make sure to register
EventSystem
to the scenes which display ads.(Normally it is automatically registered when UI such as Canvas are added to scene) - Activate
GraphicRaycaster
ofCanvas
that display ads.