using System; using UnityEngine; public class LuckyGameCupCounter : MonoBehaviour { public int objectCount = 0; public int refillobjectCount = 0; Action m_actcount; bool isRefill; public void Set(Action actcount) { m_actcount = actcount; EndRefill(); } public void StartRefill() { isRefill = true; } public void EndRefill() { refillobjectCount = 0; isRefill = false; } void OnTriggerEnter2D(Collider2D other) { if (other.CompareTag("LuckyGameObj")) // 오브젝트에 Tag 지정 { objectCount++; m_actcount(objectCount); if (isRefill) ++refillobjectCount; } } void OnTriggerExit2D(Collider2D other) { if (other.CompareTag("LuckyGameObj")) { objectCount--; m_actcount(objectCount); } } }