32 lines
636 B
C#
32 lines
636 B
C#
|
|
using System;
|
||
|
|
using UnityEngine;
|
||
|
|
|
||
|
|
public class LuckyGameCupCounter : MonoBehaviour
|
||
|
|
{
|
||
|
|
public int objectCount = 0;
|
||
|
|
|
||
|
|
Action<int> m_actcount;
|
||
|
|
|
||
|
|
public void Set(Action<int> actcount)
|
||
|
|
{
|
||
|
|
m_actcount = actcount;
|
||
|
|
}
|
||
|
|
|
||
|
|
void OnTriggerEnter2D(Collider2D other)
|
||
|
|
{
|
||
|
|
if (other.CompareTag("LuckyGameObj")) // 오브젝트에 Tag 지정
|
||
|
|
{
|
||
|
|
objectCount++;
|
||
|
|
m_actcount(objectCount);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
void OnTriggerExit2D(Collider2D other)
|
||
|
|
{
|
||
|
|
if (other.CompareTag("LuckyGameObj"))
|
||
|
|
{
|
||
|
|
objectCount--;
|
||
|
|
m_actcount(objectCount);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|