- Home /
Making Interstitial appear when the counter reaches a certain number
Hey, I have an app that I want to make interstitial advertisement appear when a counter gets to a certain number. I have understood that i need to call these two functions( RequestInterstitial(); And ShowInterstitial();) I have tried to call it from another script, by using this on the start of another script. Then later say the ShowInterstitial(); inside the Void Updater(), If a value is equal to 5. But it just says that "object reference not set to an instance of an object" So how do I actually call the function from another script?? What do I need to include to make it work. Thanks in advance for any help :)
Answer by OpenXcell-Studio · Oct 17, 2016 at 06:38 AM
in script of GoogleMobileAdsDemoScript.cs
write this
public static GoogleMobileAdsDemoScript Instance; void Awake() { Instance = this; }
and drag script GoogleMobileAdsDemoScript.cs on one empty game object in scene.
now go to your script where you want to call full ads and write
GoogleMobileAdsDemoScript .Instance.RequestInterstitial();//this RequestInterstitial must be public method not private
I put the Google$$anonymous$$obileAdsScript.Instance.RequestInterstitial in the Void Start(), then i put the Google$$anonymous$$obileAdsScript.Instance.ShowInterstitial under the IF statment in the Void Update() But I get the Error: So what am I missing? and can the Request and Show Interstitial be at the same place? Only assignment, call, increment, decrement, and new object expressions can be used as a statement
Google$$anonymous$$obileAdsDemoScript .Instance.RequestInterstitial();