Hi,
Context: Advertisement 4.0.1, Unity 2020.3.29f1
I have a CMyAds script created each time I load a new level. This class has a IUnityAdsShowListener interface and shows ads like this:
Advertisement.Show(adId, this);
The problem is that when calling this a second time (for example in the next level), the previous IUnityAdsShowListener interface (which was destroyed with the previous level) is still called, and of course it leads to an error :
MissingReferenceException: The object of type ‘CMyAds’ has been destroyed but you are still trying to access it.
How can I force the Advertisement library to forgot about the previous class, and just use the new listener?
In previous versions for Advertisement I had something like this:
private void OnDestroy()
{
Advertisement.RemoveListener(this);
}
but it’s now deprecated since 4.0.0.
Thanks,
Lionel