when i play my game without ads in the editor mode it works fine but when i activate the ad service unity closes.
(i only want it for android)
this is my script
Code
using UnityEngine;
using UnityEngine.Advertisements;
public class ads : MonoBehaviour
{
public test test;
private void Start()
{
test = test.GetComponent<test>();
}
public void ShowRewardedAd()
{
if (Advertisement.IsReady("rewardedVideo"))
{
var options = new ShowOptions { resultCallback = HandleShowResult };
Advertisement.Show("rewardedVideo", options);
}
}
private void HandleShowResult(ShowResult result)
{
switch (result)
{
case ShowResult.Finished:
Debug.Log("The ad was successfully shown.");
test.watchedAd();
break;
case ShowResult.Skipped:
Debug.Log("The ad was skipped before reaching the end.");
break;
case ShowResult.Failed:
Debug.LogError("The ad failed to be shown.");
break;
}
}
}
it gives me this error:
Assets/ads.cs(2,19): error CS0234: The type or namespace name `Advertisements' does not exist in the namespace `UnityEngine'. Are you missing an assembly reference?
and this one:
Assets/ads.cs(22,35): error CS0246: The type or namespace name `ShowResult' could not be found. Are you missing an assembly reference?
how can i fix this?!
thanks alot,
Kelvin