Character.cs
public class Character : Monobehaviour
{
public delegate void Boost(Character target);
public Boost playerBoost;
~중략~
void Start()
{
playerBoost(this);
}
}
Booster.cs
public class Booster : Monobehaviour
{
~중략~
void Awake()
{
Character player = FindObjectOfType<Character>();
player.playerBoost += HealthBoost; //Delegate
player.playerBoost += ShieldBoost;
player.playerBoost += DamageBoost;
}
}
public event Boost playerBoost;
처럼 delegate 형 앞에 event 키워드 사용 가능 player.playerBoost += HealthBoost;
player.playerBoost = DamageBoost; //덮어씌어져버림 **문제**
player.playerBoost(player);
실행