What Is It?
A ScriptableObject event channel is an asset in your Project, such as OnPlayerDied.asset. The object that raises the event has a field pointing at the asset and calls Raise(). Listeners point at the same asset and register with it. Raiser and listeners never reference each other; they only reference the file.
The idea was popularised by Ryan Hipple's Unite Austin 2017 talk “Game Architecture with Scriptable Objects”. Its core pieces are a GameEventSO that keeps a list of listeners, and a generic GameEventListener MonoBehaviour whose UnityEvent response is wired in the Inspector. A typed variant such as IntEventChannelSO exposes event Action<int> for code-side listeners that need a payload.
Because assets exist outside any scene, the channel works across additive scenes, and a prefab can reference it directly, something it can never do with a scene object. That is the difference from Observer (you need the subject's reference) and from a static Event Bus (the wiring lives in code, invisible in the Inspector). Here the connection is a visible, draggable asset reference.
When Is It Used?
Use it when designers should be able to wire reactions without code: “when OnPlayerDied is raised, play this animation, enable that panel”.
It shines in projects split into several additive scenes (gameplay, UI, audio) and in prefab-heavy projects, where a direct reference between the two sides is impossible or fragile.
Avoid it for very high-frequency events and for tightly coupled local logic. One asset per event can become hundreds of small files, and searching the Project for “who listens to this?” is slower than reading code.
Interactive Demo
Click the controls and watch the objects collaborate. The console mirrors what the C# code below would log.
Code
using UnityEngine;
namespace Patterns.GameProgramming.SOEvents
{
/// <summary>
/// The raiser. Its only links to the outside world are two channel assets
/// dragged in from the Project window; it never finds or references a listener.
/// </summary>
public class PlayerHealth : MonoBehaviour
{
[SerializeField] private int maxHealth = 100;
[Header("Event channels (assets)")]
[SerializeField] private IntEventChannelSO healthChanged; // HealthChanged.asset
[SerializeField] private GameEventSO playerDied; // OnPlayerDied.asset
private int current;
private void Awake() => current = maxHealth;
public void TakeDamage(int amount)
{
if (current <= 0) return;
current = Mathf.Max(0, current - amount);
healthChanged.Raise(current);
if (current == 0)
playerDied.Raise();
}
}
}using System.Collections.Generic;
using UnityEngine;
namespace Patterns.GameProgramming.SOEvents
{
/// <summary>
/// An event channel that lives in the Project as an asset (OnPlayerDied.asset).
/// Anything in any scene or prefab can reference it, so raiser and listeners
/// meet at the asset instead of at each other.
/// </summary>
[CreateAssetMenu(menuName = "Events/Game Event", fileName = "NewGameEvent")]
public class GameEventSO : ScriptableObject
{
[TextArea] [SerializeField] private string description;
private readonly List<GameEventListener> listeners = new();
public void Raise()
{
// Iterate backwards so a listener may unregister itself while responding.
for (int i = listeners.Count - 1; i >= 0; i--)
listeners[i].OnEventRaised();
}
public void Register(GameEventListener listener)
{
if (!listeners.Contains(listener))
listeners.Add(listener);
}
public void Unregister(GameEventListener listener) => listeners.Remove(listener);
}
}using UnityEngine;
using UnityEngine.Events;
namespace Patterns.GameProgramming.SOEvents
{
/// <summary>
/// Generic glue component: pick a GameEventSO asset and wire the response
/// with a UnityEvent in the Inspector. No custom script per reaction.
/// </summary>
public class GameEventListener : MonoBehaviour
{
[SerializeField] private GameEventSO gameEvent;
[SerializeField] private UnityEvent response;
private void OnEnable()
{
if (gameEvent != null) gameEvent.Register(this);
}
private void OnDisable()
{
if (gameEvent != null) gameEvent.Unregister(this);
}
public void OnEventRaised() => response.Invoke();
}
}using System;
using UnityEngine;
namespace Patterns.GameProgramming.SOEvents
{
/// <summary>
/// A typed channel with a payload, for code-side listeners.
/// Subscribe with += in OnEnable and -= in OnDisable, like any C# event.
/// </summary>
[CreateAssetMenu(menuName = "Events/Int Event Channel", fileName = "NewIntChannel")]
public class IntEventChannelSO : ScriptableObject
{
public event Action<int> OnRaised;
public void Raise(int value)
{
if (OnRaised == null)
Debug.Log($"{name} raised ({value}) with no listeners.", this);
OnRaised?.Invoke(value);
}
}
}Before & After
Real-world smell: a game-over screen wired through a static class and a scene search. Here is the code without the pattern, the refactored version, and the exact diff between them.
! What’s wrong with it?
GameOverScreen subscribes to the static GameEvents.PlayerDied event and calls FindAnyObjectByType<ScoreKeeper>() in Awake to read the final score.
When the UI moves to its own additive scene, the search runs before the gameplay scene is loaded and returns null. Nothing in the Inspector shows that the screen depends on GameEvents or ScoreKeeper, and every script in the project can raise GameEvents.RaisePlayerDied().
✓ What changed
- The
scoreKeeperfield, theFindAnyObjectByTypecall and the staticGameEventsclass are gone. - A serialized
IntEventChannelSO playerDiedfield references a channel asset, wired in the Inspector and visible to designers. - The final score arrives as the event payload in
Show(int finalScore), so the screen no longer reaches into another scene for data. - Subscription still pairs
+=inOnEnablewith-=inOnDisable, now on the asset'sOnRaisedevent.
using System;
using TMPro;
using UnityEngine;
namespace Patterns.GameProgramming.SOEvents
{
/// <summary>
/// Without event channels: the screen listens to a global static class
/// and searches the scene for the object that owns the score.
/// </summary>
public class GameOverScreen : MonoBehaviour
{
[SerializeField] private GameObject panel;
[SerializeField] private TMP_Text finalScoreLabel;
private ScoreKeeper scoreKeeper;
private void Awake()
{
// Returns null when the UI lives in an additive "UI" scene
// that is loaded before the gameplay scene.
scoreKeeper = FindAnyObjectByType<ScoreKeeper>();
}
private void OnEnable() => GameEvents.PlayerDied += Show;
private void OnDisable() => GameEvents.PlayerDied -= Show;
private void Show()
{
finalScoreLabel.text = scoreKeeper.Score.ToString();
panel.SetActive(true);
}
}
/// <summary>The project-wide static hub every script reaches into.</summary>
public static class GameEvents
{
public static event Action PlayerDied;
public static void RaisePlayerDied() => PlayerDied?.Invoke();
}
}using TMPro;
using UnityEngine;
namespace Patterns.GameProgramming.SOEvents
{
/// <summary>
/// With event channels: the screen references an asset, not a scene object.
/// The final score arrives as the event's payload.
/// </summary>
public class GameOverScreen : MonoBehaviour
{
[SerializeField] private GameObject panel;
[SerializeField] private TMP_Text finalScoreLabel;
// Drag the PlayerDiedScore.asset channel here. Payload: the final score.
[SerializeField] private IntEventChannelSO playerDied;
private void OnEnable() => playerDied.OnRaised += Show;
private void OnDisable() => playerDied.OnRaised -= Show;
private void Show(int finalScore)
{
finalScoreLabel.text = finalScore.ToString();
panel.SetActive(true);
}
}
}Advantages & Disadvantages
+ Advantages
- Wiring is visible and editable in the Inspector; designers can add reactions with
GameEventListenerand aUnityEvent. - Works across scenes and from prefabs, because the asset is not owned by any scene.
- Easy to test: drop a listener in an empty scene and raise the asset from a button or a custom Inspector.
− Disadvantages
- Many small assets to name, organise and find; the Project window becomes part of your architecture.
- Assets are shared and persistent, which is easy to misunderstand: in the Editor, serialized values changed during Play Mode stay changed on the asset after you stop.
- Flow is spread between code and serialized data, so “who reacts to this?” needs Find References In Scene or a custom tool.
Tips
- 01Register in
OnEnableand unregister inOnDisable, exactly like C# events, so disabled and unloaded objects drop off the list. - 02Add a custom Inspector with a Raise button to the channel asset; it makes testing a scene in isolation trivial.
- 03Use a generic base like
EventChannelSO<T>and tiny subclasses (IntEventChannelSO,VoidEventChannelSO) because Unity cannot serialize open generic asset types. - 04Keep a description field on each asset explaining who raises it, and group channels in one folder per feature.
- 05Unity's own Open Projects sample “Chop Chop” uses this style throughout; it is a good reference for structuring channels at scale.