-
Notifications
You must be signed in to change notification settings - Fork 4
Return To Play Ad Object
d.eshenko edited this page Oct 18, 2022
·
10 revisions
⚡ Before you start
Make sure you have correctly initialized Mediaiton Manager via Script or Unity Editor.
Implementation by UnityEditor | Script C#
- Add a ReturnToPlayAdObject to the scene
- Load Ad callbacks
- Content callbacks
- Unity Events sample
- Use ReturnToPlayAdObject from script
This guide explains how to integrate interstitial ads into a Unity app.
- Add a GameObject to your scene using
GameObject > Create Empty
in the Unity Editor. - Add Component
CleverAdsSolutions/Return To Play Ad Object
in the inspector to new GameObject. - Select Manager ID from the settings asset for each runtime platform.
- Check flag
allowReturnToPlayAd
⭐ An ReturnToPlayAdObject does not have any rendered components. Therefore, you can place the GameObject anywhere in the scene.
-
On Ad Loaded
The event is invoked when the ad has finished loading. -
On Ad Failed To Load
The event is invoked when the ad fails to load. The Message parameter describes the type of failure that occurred.
-
On Ad Failed To Show
The event is invoked when the ad failed to show. The Message parameter describes the type of failure that occurred. -
On Ad Shown
The event is invoked when the ad is shown. -
On Ad Clicked
The event is invoked when the user clicks on the ad. -
On Ad Closed
The event is invoked when the ad is closed.
⭐ Using Ad objects automatically enable Execute Events On Unity Thread and invoke all callbacks in the Unity Thread to safe use of Unity API.
You can implement functions that correspond to ad callbacks. For example, if you want to handle when the ad fails to shown:
- Create a function compatible with the ad callback in custom component.
public void OnReturnToPlayAdFailedToShow(string reason) {
Debug.Log("ReturnToPlay ad failed to show: " + reason);
}
- Attach the script which contains the above function to any GameObject in the scene.
- Click the + button, then drag & drop the GameObject that you've attached the script to.
- Select the function that you want to link to the ad callback. For the parameterized ad callbacks, select the function to accept the dynamic variable so you can get the parameter value from the SDK.
Get the ReturnToPlay ad instance from the script:
ReturnToPlayAdObject adObject = adObject.GetComponent<ReturnToPlayAdObject>();
Enable ReturnToPlay ad:
adObject.allowReturnToPlayAd = true;
Disable ReturnToPlay ad:
adObject.allowReturnToPlayAd = false;
What’s Next?
- Follow our integration guides and implement our Ad Units:
- See the Privacy page to learn how to ensure that your application complies with privacy regulations.
- Project Setup
- Configuring SDK
- Include Android
- Include iOS
- Additional mediation steps
- App-ads.txt🔗