- Home /
Unity Ads using monetization sdk 3.0 not working
I downloaded the unity monetization 3.0 and the ads work in the inspector but I get these errors: Initializing Unity Ads. unityengine.Advertisements.Creator.LoadRuntime() and ArgumentNullException: Value cannot be null. parameter name: type.
The ads work in the inspector but not when I build to IOS or android, here is my script:
public string placementId = "rewardedVideo";
private bool testMode = false;
private string gameId = "1234567";
private GameManager gameManager;
void Start()
{
gameManager = FindObjectOfType<GameManager>();
if(Application.platform== RuntimePlatform.IPhonePlayer)
{
gameId = "1234567";
}
else if (Application.platform == RuntimePlatform.Android)
{
gameId = "7654321";
}
if (Monetization.isSupported)
{
Monetization.Initialize(gameId, testMode);
}
}
public void ShowAd()
{
StartCoroutine(WaitForAd());
}
IEnumerator WaitForAd()
{
while (!Monetization.IsReady(placementId))
{
yield return null;
}
ShowAdPlacementContent ad = null;
ad = Monetization.GetPlacementContent(placementId) as ShowAdPlacementContent;
if (ad != null)
{
ad.Show(AdFinished);
}
}
void AdFinished(ShowResult result)
{
if (result == ShowResult.Finished)
{
GameData.gameData.saveData.lives++;
if (gameManager != null)
{
gameManager.LoadData();
}
}
}
I have ads turned on and I put my games ID in the game ID string. I am using the latest version of unity. when I click on the ad button on android device after its built nothing happens and the add does not launch. is there a reason it would work in the inspector and not when I build the game? Thanks
Your answer
Follow this Question
Related Questions
Unity Ads: Non-fullscreen ads? 1 Answer
Delete a project from unity services? 2 Answers
Unity Ads not working on my Android device but works on many other devices 1 Answer
unity unable to convert to dex format, need help fast. 0 Answers
Applovin error - MissingReferenceException: No parent activity specified 0 Answers