title: Show Unity Ads Every 5 times scene is loaded. (Unity 3D)
body: <p>I want to show ads in my 2D game every 5 times the scene is loaded. I tried this:</p>
  
  <pre><code>void Update ()
  {
      if(GameObject.Find ("Main Camera").transform.position.x == -23) {
          showNumber += 1;
          if(showNumber == 5) {
              if(Advertisement.isReady()){
                  Advertisement.Show();
              }
          }
          if(showNumber &gt; 5) {
              showNumber = 1;
          }
      }
  }
  </code></pre>
  
  <p>How do I make the number only change only once so it would only change once when the main camera's position is -23. Right not it changes every frame.</p>
  
  <p>Edit</p>
  
  <pre><code>void OnTriggerEnter(Collider other) {
      DontDestroyOnLoad (gameObject);
      if(other.name == "Main Camera") {
          showNumber +=1;
          if(showNumber == 5) {
              if(Advertisement.isReady()){
                  Advertisement.Show();
              }
          }
          if(showNumber &gt; 5) {
              showNumber = 0;
          }
      }
  }
  </code></pre>