Quantcast
Channel: Questions in topic: "ads"
Viewing all articles
Browse latest Browse all 1416

Why is resultCallback coming up with a NullReferenceException in Javascript?

$
0
0
So I am trying to use Unity Ads with javascript, but each time I try to click on the button it come up with: "NullReferenceException: Object reference not set to an instance of an object AdButton.OnMouseDown () (at Assets/AdButton.js:22) UnityEngine.SendMouseEvents:DoSendMouseEvents(Int32) " Here is the code that I am using, any help would be greatly appreciated! #pragma strict var ad : UnityEngine.Advertisements.Advertisement; function HandleShowResult (result: UnityEngine.Advertisements.ShowResult) { switch (result) { case UnityEngine.Advertisements.ShowResult.Finished : Debug.Log("The ad was successfully shown."); break; case UnityEngine.Advertisements.ShowResult.Skipped : Debug.Log("The ad was skipped"); break; case UnityEngine.Advertisements.ShowResult.Failed : Debug.LogError("The ad failed to be shown."); break; } } function OnMouseDown () { if (ad.IsReady("rewardedVideo")) { var options : UnityEngine.Advertisements.ShowOptions; options.resultCallback = HandleShowResult; ad.Show("rewardedVideo", options); } }

Viewing all articles
Browse latest Browse all 1416

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>