title: What's the best practice to using the static variable in C# of Unity
body: <p>According to this <a href="https://www.youtube.com/watch?v=SOmBhbVz5yQ&amp;feature=youtu.be&amp;t=429" rel="nofollow noreferrer">tutorial demonstrated on youtube</a></p>
  
  <p>It is working to make a static variable to hold the score and change it in other scripts when the player should be awarded, but it also advised that using static variable in C# script of Unity might not be recommended.</p>
  
  <p>Flowing is what I do to construct the scoring system:</p>
  
  <p>in <code>ScoreManger</code> which was bonded to an UI Text component to show the score:</p>
  
  <pre><code>public class ScoreManager : MonoBehaviour {
      public static int score;
      Text text;
      private void Awake()
      {
          text = GetComponent&lt;Text&gt;();
      }
      private void FixedUpdate()
      {
          text.text = "Score: " + score;
      }
  }
  </code></pre>
  
  <p>And the procedure to add the score:</p>
  
  <pre><code>private void OnCollisionEnter2D(Collision2D collision)
  {
      if (collision.gameObject.CompareTag("Player"))
      {
          ScoreManager.score = ScoreManager.score + score;
          Destroy(gameObject);
      }
  }
  </code></pre>
  
  <p>So what's the best way to do this without a static variable, and if someone could explain why using a static variable is not recommended will be more grateful.</p>
  
  <h2>EDIT</h2>
  
  <p>Have tried the event handle way as @rogalski demonstrated in the answer, but the IDE shows that there is an error for type conversion on the lambda function of <code>ExecuteEvents.Execute&lt;T&gt;</code>
  <a href="https://i.stack.imgur.com/Xw2vA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Xw2vA.png" alt="enter image description here"></a></p>