title: Unity - How to add score after destroying object in unity 2D?
body: <p>Before this, I have made a scoring section to my program that used Invoke repeating every 1s. Now, I have problem how to make my scoring counter add an additional score when I destroy some objects.</p>
  
  <pre><code>using UnityEngine;
  using System.Collections;
  using UnityEngine.UI;
  
  public class UIManager : MonoBehaviour
  {
  
    public Button[] buttons;
    public Button pauseButton;
    public Image[] images;
    public Text scoreText;
    public Text highScoreText;
    public Text yourScoreText;
    public Text text;
    bool gameOver;
    int score;
    levelscroller level;
    CoinMove cm;
    void Start()
    {
        gameOver = false;
        score = 0 + cm.plus;
        InvokeRepeating("scoreUpdate", 1.0f, 1.0f);
    }
    void Update()
    {
        storeHighScore(score);
        scoreText.text = "" + score;
        yourScoreText.text = "" + score;
        highScoreText.text = "" + PlayerPrefs.GetInt("highscore");
    }
    void scoreUpdate()
    {
        if (gameOver == false)
        {
            score += 1;
        }
    }
    void storeHighScore(int newHighscore)
    {
        int oldHighscore = PlayerPrefs.GetInt("highscore", 0);
        if (newHighscore &gt; oldHighscore)
        {
            PlayerPrefs.SetInt("highscore", newHighscore);
            oldHighscore = newHighscore;
            PlayerPrefs.Save();
        }
    }
  </code></pre>
  
  <p>Another class:</p>
  
  <pre><code>using UnityEngine;
   using System.Collections;
   public class CoinMove : MonoBehaviour
   {
    public float Speed;
    public int plus = 0;
    UIManager ui;
    void Start()
    {
  
    }
    void Update()
    {
        transform.Translate(new Vector3(0, -1, 0) * Speed * Time.deltaTime);
        //if (Input.touchCount &gt; 0 || Input.GetTouch(0).phase == TouchPhase.Began)
        //{
        //    Destroy(transform.gameObject);  
        //}
    }
    private void OnMouseDown()
    {
        Destroy(gameObject);
        plus += 10;
    }
  }
  </code></pre>
  
  <p>It just make the counter of score totally 0 and not do the increment.</p>