- Home /
Question by
cristina_mox · Mar 24, 2021 at 08:45 AM ·
adsconvertthis
Ad Manager
Hello,
For some reason I cannot implement the AdMAnager correctly. The line " Advertisement.AddListener(this);" is giving me an error. The error: cannot convert from 'AdManager' to 'UnityEngine.Advertisement.IUnityadsListener'
Can anybody please help me
public class AdManager : MonoBehaviour, IUnityAdsListener
{
public static AdManager instance;
private void Start()
{
if (instance == null)
{
instance = this;
DontDestroyOnLoad(gameObject);
Advertisement.AddListener(this);
Advertisement.Initialize(storeID, testMode);
}
else
{
Destroy(gameObject);
}
}
}
Comment
Answer by mmkhatri25 · Mar 24, 2021 at 01:00 PM
Hi, you need to add IUnityAdsListener like this -
public void OnUnityAdsDidFinish (string placementId, ShowResult showResult)
{
// Define conditional logic for each ad completion status:
switch(showResult)
{
case ShowResult.Finished:
// Reward the user for watching the ad to completion.
break;
case ShowResult.Skipped:
// Do not reward the user for skipping the ad.
break;
case ShowResult.Failed:
Debug.LogWarning (“The ad did not finish due to an error.);
break;
}
}
public void OnUnityAdsReady (string placementId)
{
if (placementId != myPlacementId) return;
adsAreReady = true;
}
public void OnUnityAdsDidError (string message)
{
// Log the error.
}
public void OnUnityAdsDidStart (string placementId)
{
// Optional actions to take when the end-users triggers an ad.
}
Your answer
Follow this Question
Related Questions
JS to C# convert problem 2 Answers
"Max couldn't convert the max file to an FBX file!" error 1 Answer
convert float to color 1 Answer
Converting Maya scene with lightmaps in Unity 1 Answer
After Capsule Collision, change into another object. 1 Answer