Ho un evento che sto utilizzando, quindi non capisco cosa significhi realmente questo avvertimento. Qualcuno può chiarire?Avviso compilatore CS0067: l'evento non viene mai utilizzato
public abstract class Actor<T> : Visual<T> where T : ActorDescription
{
#region Events
/// <summary>
/// Event occurs when the actor is dead
/// </summary>
public event Action Dead;
#endregion
/// <summary>
/// Take damage if the actor hasn't taken damage within a time limit
/// </summary>
/// <param name="damage">amount of damage</param>
public void TakeDamage(int damage)
{
if (damage > 0 && Time.time > m_LastHitTimer + m_DamageHitDelay)
{
m_CurrentHealth -= damage;
if (m_CurrentHealth <= 0)
{
m_CurrentHealth = 0;
if (Dead != null)
Dead();
}
else
StartCoroutine(TakeDamageOnSprite());
m_LastHitTimer = Time.time;
}
}
Nella mia altra classe, mi registro e annullare la registrazione per l'evento:
if (m_Player != null)
m_Player.Dead += OnPlayerDead;
if (m_Player != null)
m_Player.Dead -= OnPlayerDead;
Ohhhh. Questo ha perfettamente senso !! Grazie! –