Quantcast
Channel: Questions in topic: "ads"
Viewing all articles
Browse latest Browse all 1416

Not sure how to get OnUnityAdsShowClick working. Please help.

$
0
0
What I'm trying to achieve:- Play an Interstitial ad. And then run a function only once the ad has been completed/skipped/closed.. Using Advertisement Package 3.7.3 I'm using the example code form the Unity doc. Added LoadAd() to the click action of a button. And called ShowAd() from OnUnityAdsAdLoaded(). The test ad is showing up in the editor, but on clicking Close or Skip nothing is happening.. In fact nothing that I add to OnUnityAdsShowClick is running, not even the Debug.log statement. I'm a newbie. Not sure what I'm doing wrong. Here is my code. using UnityEngine; using UnityEngine.Advertisements; public class InterstitialAdExample : MonoBehaviour, IUnityAdsLoadListener, IUnityAdsShowListener { [SerializeField] string _androidAdUnitId = "Interstitial_Android"; [SerializeField] string _iOsAdUnitId = "Interstitial_iOS"; string _adUnitId; void Awake() { _adUnitId = (Application.platform == RuntimePlatform.IPhonePlayer) ? _iOsAdUnitId : _androidAdUnitId; } public void LoadAd() { // I call LoadAd() on clicking a button. Debug.Log("Loading Ad: " + _adUnitId); Advertisement.Load(_adUnitId, this); } public void OnUnityAdsAdLoaded(string adUnitId) { ShowAd(); } public void OnUnityAdsFailedToLoad(string adUnitId, UnityAdsLoadError error, string message) { Debug.Log($"Error loading Ad Unit: {adUnitId} - {error.ToString()} - {message}"); } public void ShowAd() { Debug.Log("Showing Ad: " + _adUnitId); Advertisement.Show(_adUnitId, this); } public void OnUnityAdsShowFailure(string adUnitId, UnityAdsShowError error, string message) { Debug.Log($"Error showing Ad Unit {adUnitId}: {error.ToString()} - {message}"); } public void OnUnityAdsShowStart(string adUnitId) { Debug.Log("Ad started showing"); } public void OnUnityAdsShowClick(string adUnitId) { } public void OnUnityAdsShowComplete(string adUnitId, UnityAdsShowCompletionState showCompletionState) { Debug.Log("Ad complete"); //Tried adding actions here, but it doesn't run } }

Viewing all articles
Browse latest Browse all 1416

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>