title: Unity3d sometimes game ending condition don't trigger
body: <p>I have a simple action-arcade game with player and multiple enemies. I have wrote a game such that when all enemies are dead the level ends. I keep track of enemies bu having a central GameplayController which has a static int called enemiescount. I increment this value at in the awake method of a script attached to each of my enemies object, and when and enemy dies I call a method to this gameplay controller named CountEnemies which decrement the variable and if it equals to zero ends the level.</p>
  
  <p>Here is the code to my CountEnemies methid called by the enemies class:</p>
  
  <pre><code>    GameplayController.instance.CountEnemies();
  </code></pre>
  
  <p>where instance just returns the singleton instance of the GameplayController.</p>
  
  <p>Here's the code to my CountEnemies method:</p>
  
  <pre><code>    Debug.Log("Inside Count Enemies");
      Debug.Log("Count Enemies before: " + enemiesCount);
      enemiesCount--;
      Debug.Log("Count Enemies after: " + enemiesCount);
  
      if (enemiesCount == 0) 
      {
          Debug.Log("Enemy Count is equal to zero");
          //Complete Level
      }
      Debug.Log("End Count Enemies");
  </code></pre>
  
  <p>Now the issue is it used to work most of the times. But randomly at somepoint when I try to run it on mobile it fails to end the level. I tried multiple times to diagnose the issue but everytime I run it on PC it seems to run flawlessly and secndly even at some rare instance it did trigger the problem, all I can found out was that even though the CountEnemies was called at every turn, through some strange cause the enemies count variable seems to not have decremented or may have been incremented.</p>
  
  <p>I have keep track of the code through Visual studio codemap and references and only in place of the Awake method did I increment the variable. Please help me sort this out or atleast suggest me how to debug it like whenever a value of this variable updates the attached debugger lets me know or something.</p>