- Home /
Question by
Josh_2002 · Feb 08, 2021 at 10:33 AM ·
admobadvertising
How to reward player when rewarded ad finishes admob
I am trying to add rewarded ads (legacy api) in my game. I copied and edited the code from google developers admob page. But I am having trouble when adding reward event when I copied this part from the admob guide site
// Called when an ad request has successfully loaded.
//rewardBasedVideo.OnAdLoaded += HandleRewardBasedVideoLoaded;
// Called when an ad request failed to load.
rewardBasedVideo.OnAdFailedToLoad += HandleRewardBasedVideoFailedToLoad;
// Called when an ad is shown.
rewardBasedVideo.OnAdOpening += HandleRewardBasedVideoOpened;
// Called when the ad starts to play.
rewardBasedVideo.OnAdStarted += HandleRewardBasedVideoStarted;
// Called when the user should be rewarded for watching a video.
rewardBasedVideo.OnAdRewarded += HandleRewardBasedVideoRewarded;
// Called when the ad is closed.
rewardBasedVideo.OnAdClosed += HandleRewardBasedVideoClosed;
// Called when the ad click caused the user to leave the application.
rewardBasedVideo.OnAdLeavingApplication += HandleRewardBasedVideoLeftApplication;
It just gives nullreferenceexeption on like 26 and ever line of this part of script. Even when I am using readymade code. I don't understand where do i need to make a reference pls help me with this.
Comment
The only thing that could be null in this code is your rewardBasedVideo.. Are you ever assigning this?
Also line numbers are not preserved when you copy code into the answer box so refer to the code itself so we know what part you're talking about :)
Your answer