Hi everyone, I implemented Unity Ads according to the Manual and it is working. However, I try to use both Reward Video Ad and Interstitial Video Ad and there seems to be an Override, because both functions reward the Player.
For testing the Functionality, I have two Buttons in my scene, the first one is connected to DisplayInterstitialAD()
and the second one is connected to DisplayRewardVideoAD()
. No matter which one is called, they both call OnUnityAdsDidFinish(...)
and thus the Reward Function.
Is it wrong to implement both Methods in one Script? I know one Workaround would be to use a bool connected to the buttons, but I think that I implemented it wrong and Unity has another solution for combining the two ad formats, right?
This is the Script:
using UnityEngine;
using UnityEngine.Advertisements;
public class AdManager : MonoBehaviour, IUnityAdsListener
{
public static AdManager instance;
public bool TestMode = true;
string game_ID = "xxxxxxx";
string myPlacementId = "rewardedVideo";
private void Start()
{
Advertisement.Initialize(game_ID, TestMode);
Advertisement.AddListener(this);
}
public void DisplayInterstitialAD()
{
Advertisement.Show();
}
public void DisplayRewardVideoAD()
{
Advertisement.Show(myPlacementId);
}
public void OnUnityAdsDidFinish(string placementId, ShowResult showResult)
{
// Define conditional logic for each ad completion status:
if (showResult == ShowResult.Finished)
{
PayReward_1();
}
else if (showResult == ShowResult.Skipped)
{
// Do not reward the user for skipping the ad.
}
else if (showResult == ShowResult.Failed)
{
Debug.LogWarning("The ad did not finish due to an error.");
}
}
public void PayReward_1()
{
//Paying the Reward to the Player
}
}