The documentation at Basic ads integration for Unity developers | Advertisement | 3.4.9 is not clear.
We have to implement IUnityAdsListener, it has 4 callbacks :
public void OnUnityAdsReady(string placementId)
{
throw new NotImplementedException();
}
public void OnUnityAdsDidError(string message)
{
throw new NotImplementedException();
}
public void OnUnityAdsDidStart(string placementId)
{
throw new NotImplementedException();
}
public void OnUnityAdsDidFinish(string placementId, ShowResult showResult)
{
throw new NotImplementedException();
}
The only thing we can do is call Initialize:
Button myButton;
public string myPlacementId = "rewardedVideo";
void Start () {
myButton = GetComponent <Button> ();
// Set interactivity to be dependent on the Placement’s status:
myButton.interactable = Advertisement.IsReady (myPlacementId);
// Map the ShowRewardedVideo function to the button’s click listener:
if (myButton) myButton.onClick.AddListener (ShowRewardedVideo);
// Initialize the Ads listener and service:
Advertisement.AddListener (this);
Advertisement.Initialize (gameId, true);
}
Then our button will call :
// Implement a function for showing a rewarded video ad:
void ShowRewardedVideo () {
Advertisement.Show (myPlacementId);
}
The button is only activated if we received the OnUnityAdsReady event. However there is no LoadAd method, is the Ad downloaded when we call Initialize only?
What happens if we want to display the ad a second time? We have to destroy this gameobject and call initialize again?
How do I tell the Advertisement API to load a new ad after the player watched one ad? Cause if 1 ad comes the button will activate and nothing says that the OnUnityAdsReady event will be called again.