Question by
vanceAllen85 · Oct 26, 2015 at 05:51 PM ·
scripting problemadsmodulus
C# Advertisment every so many plays
Hey guys,
I'm trying to play an ad every so many new games. (My game is a play/die/retry type game).
My thinking is that I can establish an incremental adding integer like this:
void Start () {
numOfGames = PlayerPrefs.GetInt ("newGames");
add1 = numOfGames += 1;
PlayerPrefs.SetInt ("newGames", add1);
PlayerPrefs.Save ();
}
in another script I call the ads based on if the number of new games is a multiple of 4 like this:
using UnityEngine;
using System.Collections;
using UnityEngine.Advertisements;
public class adsAtAnInterval : MonoBehaviour {
[SerializeField] string gameID = "00MYID00";
public int gameSessionInt;
public int modulo;
void Awake(){
Advertisement.Initialize (gameID, true);
}
// Use this for initialization
void Start () {
gameSessionInt = PlayerPrefs.GetInt ("newGames");
modulo = gameSessionInt % 4;
advertAtInterval ();
}
void advertAtInterval(){
if (modulo == 0 && Advertisement.IsReady()) {
Advertisement.Show("rewardedVideo");
}
}
}
Regardless if modulo == 0, my ads are not showing. Anyone have any thoughts? Much appreciated! -A
Comment
Your answer
Follow this Question
Related Questions
Unity Ads detect if player has internet 0 Answers
Scripting errors in Unity Ads Import 1 Answer
Admob Errors 1 Answer
Unity Ads only showing Test Ads 0 Answers