Use Visual and Script Listeners in the Same Project
Bind a scene HUD in the Inspector and let spawned enemies register their own callbacks when enabled. Both can reference the same typed event asset. Give each listener an owner so it is clear who configures it and when it is removed.
Bind scene objects in the Inspector
To wire a level door, HUD, or audio controller, find the event in Game Event Editor and open Game Event Behavior. Add the target objects and methods under Event Action.
One death event can update the overlay, open the result panel, play a sound, and disable input. Set the event's Action Condition when the entire action list shares a condition.
If the sound needs its own condition, give it a typed Receiver and configure that component's Action Condition. The camera, HUD, and other listeners can keep their own rules.
Register runtime instances in C#
Assign event assets on the prefab and pair callback registration with the instance's enabled state. This listener works on enemies that can be disabled and returned to a pool.
using TinyGiants.GES.Runtime;
using UnityEngine;
using UnityEngine.AI;
public sealed class EnemyPauseListener : MonoBehaviour
{
[GameEventDropdown, SerializeField] private GameEvent onPauseGame;
[GameEventDropdown, SerializeField] private GameEvent onResumeGame;
[SerializeField] private NavMeshAgent agent;
private void OnEnable()
{
if (onPauseGame != null) onPauseGame.AddListener(Freeze);
if (onResumeGame != null) onResumeGame.AddListener(Unfreeze);
}
private void OnDisable()
{
if (onPauseGame != null) onPauseGame.RemoveListener(Freeze);
if (onResumeGame != null) onResumeGame.RemoveListener(Unfreeze);
}
private void Freeze() => SetPaused(true);
private void Unfreeze() => SetPaused(false);
private void SetPaused(bool paused)
{
if (agent != null && agent.isOnNavMesh)
agent.isStopped = paused;
}
}
Assign the pause and resume events on the enemy prefab. Call Raise() on the corresponding asset from the pause menu or controller. In Play Mode, return an enemy to the pool and enable it again to verify that each instance responds once.
For a prefab that only needs to call a configured method, add a typed Receiver to the prefab. It manages registration when each instance is enabled or disabled.
Share the same event asset
- Apply the health change in code, then raise
OnEnemyDamagedwith the integer damage value. The HUD receives that value through its dynamic callback. - Add a separate camera Receiver with an Action Condition that checks for damage greater than
20. The camera shakes on heavy hits. - Let the wave manager raise
OnWaveCompleteafter it confirms the last enemy's death. Use Flow Graph to schedule the reward panel and the next-wave event.
Keep state changes and the decision to raise an event in code. Configure callback targets, presentation conditions, and timing in the Inspector.
When script callbacks need explicit ordering, use AddPriorityListener and clean up with RemovePriorityListener. Higher values run first within the priority listener group.
