Set Listener Order for a GES Event
If a damage event changes health and refreshes the HUD, register both listeners in the same priority tier and give the data update higher priority. Use the listener execution stages to check the order when the event mixes Inspector actions with C# callbacks.
Set priorities within one stage
Register the health update and the HUD refresh as Priority listeners. Give the health update the higher number. Each callback receives the original event argument, so apply damage reduction inside the callback that writes health.
using TinyGiants.GES.Runtime;
using UnityEngine;
public sealed class DamageListeners : MonoBehaviour
{
[GameEventDropdown, SerializeField] private Int32GameEvent onPlayerDamaged;
[SerializeField] private int armor;
[SerializeField] private int health = 100;
private void OnEnable()
{
onPlayerDamaged.AddPriorityListener(ApplyDamage, priority: 100);
onPlayerDamaged.AddPriorityListener(RefreshHealthUI, priority: 25);
}
private void OnDisable()
{
onPlayerDamaged.RemovePriorityListener(ApplyDamage);
onPlayerDamaged.RemovePriorityListener(RefreshHealthUI);
}
private void ApplyDamage(int amount)
{
health = Mathf.Max(0, health - Mathf.Max(0, amount - armor));
}
private void RefreshHealthUI(int amount)
{
Debug.Log($"Health after {amount} raw damage: {health}");
}
}
The ordered Demo gives the state update and presentation callbacks different priorities. In the first run, the HUD reads the updated health.

The chaotic run shows what stale UI looks like when the display reads health before the write.

Give dependent callbacks distinct priorities. Use names such as Model and View when several events share the same convention.
Check the dispatch order
| Stage | What runs |
|---|---|
| 1 | Basic listeners, in registration order |
| 2 | Inspector actions, when enabled |
| 3 | Priority listeners, higher values first |
| 4 | Conditional listeners, higher values first, with each predicate checked before its callback |
| 5 | Persistent listeners, higher values first |
| 6 | Trigger registrations |
| 7 | Chain registrations |
Priority applies within a stage. A Basic HUD callback runs before a Priority health update even if the update has priority 100. Move both callbacks to the Priority stage, or let the health update raise a separate event after writing the new value.
Open the event in Game Event Monitor and inspect Listeners to check where each callback is registered.

Filter a callback by its argument
Add a Conditional listener when a reaction applies only to some raises. For Int32GameEvent, the predicate receives an int.
onPlayerDamaged.AddConditionalListener(
call: HandleCriticalHit,
condition: amount => amount > 50,
priority: 75);
// When the owner stops listening:
onPlayerDamaged.RemoveConditionalListener(HandleCriticalHit);
A GameEvent<GameObject, int> passes the sender and argument to both the predicate and the callback.
onDamageFromSource.AddConditionalListener(
call: HandleBossDamage,
condition: (sender, amount) => sender != null && sender.CompareTag("Boss"),
priority: 75);
Listen across scenes
Register the callback with AddPersistentListener when the owner is a session service that survives scene loads. In the persistent-listener Demo, the audio service stays alive and continues receiving sound requests as scenes change.

private void Start()
{
DontDestroyOnLoad(gameObject);
onEnemyDied.AddPersistentListener(PlayDeathSound, priority: 10);
}
private void OnDestroy()
{
onEnemyDied.RemovePersistentListener(PlayDeathSound);
}
In the Demo scene setup, locate the service that owns the callback. Its lifetime determines when to remove the listener. Pair registration in OnEnable with removal in OnDisable if disabling the service should also mute it.

RemoveAllListeners() clears Basic, Priority, and Conditional listeners. Remove a Persistent listener with RemovePersistentListener.
Keep the callback you registered
Register a named method and pass the same method to the matching remove call. If you need a lambda, store it as a UnityAction<int> for an Int32GameEvent.
private UnityEngine.Events.UnityAction<int> _handler;
private void OnEnable()
{
_handler = amount => health -= amount;
onPlayerDamaged.AddListener(_handler);
}
private void OnDisable()
{
onPlayerDamaged.RemoveListener(_handler);
}
🚀 Global Developer Service Matrix
🇨🇳 China Developer Community
- 🛒 Unity China Asset Store
- 🎥 Bilibili Video Tutorials
- 📘 Technical Documentation
- 💬 QQ Group (1071507578)
🌐 Global Developer Community
📧 Support & Collaboration
