using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using TMPro; public class Pizza_Script : MonoBehaviour { private int Pizza = 0; [SerializeField] private TMP_Text PizzaText; private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.CompareTag("Pizza")) { Destroy(collision.gameObject); Pizza++; Debug.Log(Pizza); PizzaText.text = "" + Pizza; } } }