All posts
postApril 25, 2026

Unity Events vs C# Events

#csharp#unity#events#architecture
Unity Events vs C# Events — slide 1
csharp
using UnityEngine;
using UnityEngine.Events;
using System;

public class HealthSystem : MonoBehaviour
{
    // Inspector-wired — any designer can connect callbacks
    [SerializeField] private UnityEvent onDeath;

    // Code-wired — fast, type-safe
    public event Action<int> OnHealthChanged;

    private int _hp = 100;

    public void TakeDamage(int dmg)
    {
        _hp -= dmg;
        OnHealthChanged?.Invoke(_hp);  // C# event
        if (_hp <= 0) onDeath?.Invoke();// Unity event
    }
}