Unity 2D Віконце з монетами

2075Unity / 2D / Віконце з монетами

 

Coin2D CoinPortal2D
Coin2DPro Coin2DProSound

public UnityEngine.UI.Text t1;
public string text = "Coins: ";
public static int count = 0;
bool was = false; // аби двічі не спрацьовував

void OnTriggerEnter2D(Collider2D other)
{
  if (other.tag == "Player" && was == false)
  {
    count++;
    was = true;
    t1.text = text + count;
    Destroy(gameObject);
  }
}