API Reference
Complete reference documentation for the GameEvent system. All event types implement strict type-safe interfaces with comprehensive functionality for event-driven architecture.
All classes and interfaces are located in the TinyGiants.GameEventSystem.Runtime namespace.
using TinyGiants.GameEventSystem.Runtime;
Event Types Overviewβ
The GameEvent system provides three event type variants
| Type | Description |
|---|---|
GameEvent | Parameterless events for simple notifications |
GameEvent<T> | Single-argument events for passing typed data |
GameEvent<TSender, TArgs> | Dual-argument events for sender-aware communication |
All methods below are available across these types with appropriate parameter variations.
π Event Raising & Cancellationβ
Raise()β
Triggers the event immediately, invoking all registered listeners in execution order.
Execution Order: Basic β Priority β Conditional β Persistent β Triggers β Chains
- GameEvent
- GameEvent<T>
- GameEvent<TSender, TArgs>
void Raise();
Example:
myEvent.Raise();
void Raise(T argument);
Parameters:
| Name | Type | Description |
|---|---|---|
argument | T | The data payload to pass to all listeners |
Example:
// Raise with float value
healthEvent.Raise(50.5f);
// Raise with custom type
scoreEvent.Raise(new ScoreData { points = 100, combo = 5 });
void Raise(TSender sender, TArgs args);
Parameters:
| Name | Type | Description |
|---|---|---|
sender | TSender | The source object triggering the event |
args | TArgs | The data payload to pass to listeners |
Example:
// Raise with GameObject sender and damage data
damageEvent.Raise(this.gameObject, new DamageInfo(10));
// Raise with player sender
playerEvent.Raise(playerInstance, new PlayerAction { type = "Jump" });
Cancel()β
Stops any active Inspector-configured scheduled execution (delay or repeating) for this event asset.
void Cancel();
Example:
// Stop automatic repeating configured in Inspector
myEvent.Cancel();
This ONLY cancels schedules initiated by the Inspector's "Schedule Configuration". It does NOT cancel manual schedules created via RaiseDelayed() or RaiseRepeating(). Use CancelDelayed(handle) or CancelRepeating(handle) for those.
β±οΈ Time-Based Schedulingβ
Methods for delayed and repeating event execution. All scheduling methods return a ScheduleHandle for cancellation control.
RaiseDelayed()β
Schedules the event to fire once after a specified delay.
- GameEvent
- GameEvent<T>
- GameEvent<TSender, TArgs>
ScheduleHandle RaiseDelayed(float delay);
Parameters:
| Name | Type | Description |
|---|---|---|
delay | float | Time in seconds to wait before raising the event |
Returns: ScheduleHandle - Handle for cancellation
Example:
// Raise after 5 seconds
ScheduleHandle handle = myEvent.RaiseDelayed(5f);
// Cancel if needed
myEvent.CancelDelayed(handle);
ScheduleHandle RaiseDelayed(T argument, float delay);
Parameters:
| Name | Type | Description |
|---|---|---|
argument | T | The data to pass when the event executes |
delay | float | Time in seconds to wait before raising the event |
Returns: ScheduleHandle - Handle for cancellation
Example:
// Spawn enemy after 3 seconds
ScheduleHandle handle = spawnEvent.RaiseDelayed(enemyType, 3f);
// Cancel spawn
spawnEvent.CancelDelayed(handle);
ScheduleHandle RaiseDelayed(TSender sender, TArgs args, float delay);
Parameters:
| Name | Type | Description |
|---|---|---|
sender | TSender | The sender to pass when the event executes |
args | TArgs | The data to pass when the event executes |
delay | float | Time in seconds to wait before raising the event |
Returns: ScheduleHandle - Handle for cancellation
Example:
// Delayed damage application
ScheduleHandle handle = damageEvent.RaiseDelayed(
attackerObject,
new DamageInfo(25),
2f
);
RaiseRepeating()β
Schedules the event to fire repeatedly at fixed intervals.
- GameEvent
- GameEvent<T>
- GameEvent<TSender, TArgs>
ScheduleHandle RaiseRepeating(float interval, int repeatCount = -1);
Parameters:
| Name | Type | Description |
|---|---|---|
interval | float | Seconds between each execution |
repeatCount | int | Number of repetitions. Use -1 for infinite (default: -1) |
Returns: ScheduleHandle - Handle for cancellation
Example:
// Repeat 10 times
ScheduleHandle handle = tickEvent.RaiseRepeating(1f, repeatCount: 10);
// Repeat forever (infinite loop)
ScheduleHandle infinite = pulseEvent.RaiseRepeating(0.5f);
// Stop infinite loop
pulseEvent.CancelRepeating(infinite);
ScheduleHandle RaiseRepeating(T argument, float interval, int repeatCount = -1);
Parameters:
| Name | Type | Description |
|---|---|---|
argument | T | The data to pass with each execution |
interval | float | Seconds between each execution |
repeatCount | int | Number of repetitions. Use -1 for infinite (default: -1) |
Returns: ScheduleHandle - Handle for cancellation
Example:
// Deal damage every second, 5 times
ScheduleHandle poison = damageEvent.RaiseRepeating(5, 1f, repeatCount: 5);
// Spawn waves infinitely every 30 seconds
ScheduleHandle waves = waveEvent.RaiseRepeating(waveData, 30f);
ScheduleHandle RaiseRepeating(TSender sender, TArgs args, float interval, int repeatCount = -1);
Parameters:
| Name | Type | Description |
|---|---|---|
sender | TSender | The sender to pass with each execution |
args | TArgs | The data to pass with each execution |
interval | float | Seconds between each execution |
repeatCount | int | Number of repetitions. Use -1 for infinite (default: -1) |
Returns: ScheduleHandle - Handle for cancellation
Example:
// Regenerate health every 2 seconds, 10 times
ScheduleHandle regen = healEvent.RaiseRepeating(
playerObject,
new HealInfo(5),
2f,
repeatCount: 10
);
CancelDelayed()β
Cancels a specific delayed event created with RaiseDelayed().
bool CancelDelayed(ScheduleHandle handle);
Parameters:
| Name | Type | Description |
|---|---|---|
handle | ScheduleHandle | The handle returned by RaiseDelayed() |
Returns: bool - true if successfully cancelled, false if already executed or invalid
Example:
ScheduleHandle handle = explosionEvent.RaiseDelayed(5f);
// Cancel before explosion happens
if (explosionEvent.CancelDelayed(handle))
{
Debug.Log("Explosion defused!");
}
CancelRepeating()β
Cancels a specific repeating event created with RaiseRepeating().
bool CancelRepeating(ScheduleHandle handle);
Parameters:
| Name | Type | Description |
|---|---|---|
handle | ScheduleHandle | The handle returned by RaiseRepeating() |
Returns: bool - true if successfully cancelled, false if already finished or invalid
Example:
ScheduleHandle handle = tickEvent.RaiseRepeating(1f);
// Stop repeating
if (tickEvent.CancelRepeating(handle))
{
Debug.Log("Timer stopped!");
}
π§ Listener Managementβ
Methods to register and unregister callback functions. Listeners are invoked when the event is raised.
AddListener()β
Registers a basic listener with standard execution priority.
- GameEvent
- GameEvent<T>
- GameEvent<TSender, TArgs>
void AddListener(UnityAction call);
Parameters:
| Name | Type | Description |
|---|---|---|
call | UnityAction | Callback method with no parameters |
Example:
myEvent.AddListener(OnEventTriggered);
void OnEventTriggered()
{
Debug.Log("Event fired!");
}
void AddListener(UnityAction<T> call);
Parameters:
| Name | Type | Description |
|---|---|---|
call | UnityAction<T> | Callback method receiving typed argument |
Example:
scoreEvent.AddListener(OnScoreChanged);
void OnScoreChanged(int newScore)
{
Debug.Log($"Score: {newScore}");
}
void AddListener(UnityAction<TSender, TArgs> call);
Parameters:
| Name | Type | Description |
|---|---|---|
call | UnityAction<TSender, TArgs> | Callback receiving sender and arguments |
Example:
damageEvent.AddListener(OnDamageDealt);
void OnDamageDealt(GameObject attacker, DamageInfo info)
{
Debug.Log($"{attacker.name} dealt {info.amount} damage");
}
If the listener already exists, it will be removed and re-added to prevent duplicates.
RemoveListener()β
Unregisters a basic listener from the event.
- GameEvent
- GameEvent<T>
- GameEvent<TSender, TArgs>
void RemoveListener(UnityAction call);
Parameters:
| Name | Type | Description |
|---|---|---|
call | UnityAction | Callback method with no parameters |
Example:
myEvent.RemoveListener(OnEventTriggered);
void RemoveListener(UnityAction<T> call);
Parameters:
| Name | Type | Description |
|---|---|---|
call | UnityAction<T> | Callback method receiving typed argument |
Example:
scoreEvent.RemoveListener(OnScoreChanged);
void RemoveListener(UnityAction<TSender, TArgs> call);
Parameters:
| Name | Type | Description |
|---|---|---|
call | UnityAction<TSender, TArgs> | Callback receiving sender and arguments |
Example:
damageEvent.RemoveListener(OnDamageDealt);
RemoveAllListeners()β
Clears all Basic, Priority, and Conditional listeners from the event.
void RemoveAllListeners();
Example:
// Clean up all listeners
myEvent.RemoveAllListeners();
Does NOT remove Persistent listeners or Trigger/Chain events for safety reasons.
AddPriorityListener()β
Registers a listener with explicit execution priority. Higher priority values execute first.
- GameEvent
- GameEvent<T>
- GameEvent<TSender, TArgs>
void AddPriorityListener(UnityAction call, int priority);
Parameters:
| Name | Type | Description |
|---|---|---|
call | UnityAction | Callback method |
priority | int | Execution priority (higher = earlier, default: 0) |
Example:
myEvent.AddPriorityListener(CriticalHandler, 100);
myEvent.AddPriorityListener(NormalHandler, 50);
myEvent.AddPriorityListener(LowPriorityHandler, 10);
// Execution order: CriticalHandler β NormalHandler β LowPriorityHandler
void AddPriorityListener(UnityAction<T> call, int priority);
Parameters:
| Name | Type | Description |
|---|---|---|
call | UnityAction<T> | Callback method |
priority | int | Execution priority (higher = earlier, default: 0) |
Example:
healthEvent.AddPriorityListener(UpdateUI, 100);
healthEvent.AddPriorityListener(PlaySound, 50);
void AddPriorityListener(UnityAction<TSender, TArgs> call, int priority);
Parameters:
| Name | Type | Description |
|---|---|---|
call | UnityAction<TSender, TArgs> | Callback method |
priority | int | Execution priority (higher = earlier, default: 0) |
Example:
attackEvent.AddPriorityListener(ProcessCombat, 100);
attackEvent.AddPriorityListener(ShowVFX, 50);
RemovePriorityListener()β
Unregisters a priority listener.
- GameEvent
- GameEvent<T>
- GameEvent<TSender, TArgs>
void RemovePriorityListener(UnityAction call);
Parameters:
| Name | Type | Description |
|---|---|---|
call | UnityAction | Callback method with no parameters |
Example:
myEvent.RemovePriorityListener(OnEventTriggered);
void RemovePriorityListener(UnityAction<T> call);
Parameters:
| Name | Type | Description |
|---|---|---|
call | UnityAction<T> | Callback method receiving typed argument |
Example:
scoreEvent.RemovePriorityListener(OnScoreChanged);
void RemovePriorityListener(UnityAction<TSender, TArgs> call);
Parameters:
| Name | Type | Description |
|---|---|---|
call | UnityAction<TSender, TArgs> | Callback receiving sender and arguments |
Example:
damageEvent.RemovePriorityListener(OnDamageDealt);
AddConditionalListener()β
Registers a listener that only executes when a condition evaluates to true.
- GameEvent
- GameEvent<T>
- GameEvent<TSender, TArgs>
void AddConditionalListener(UnityAction call, Func<bool> condition, int priority = 0);
Parameters:
| Name | Type | Description |
|---|---|---|
call | UnityAction | Callback method |
condition | Func<bool> | Predicate function (null = always execute) |
priority | int | Execution priority (default: 0) |
Example:
myEvent.AddConditionalListener(
OnHealthLow,
() => playerHealth < 20,
priority: 10
);
void AddConditionalListener(UnityAction<T> call, Func<T, bool> condition, int priority = 0);
Parameters:
| Name | Type | Description |
|---|---|---|
call | UnityAction<T> | Callback method |
condition | Func<T, bool> | Predicate receiving the argument |
priority | int | Execution priority (default: 0) |
Example:
scoreEvent.AddConditionalListener(
OnHighScore,
score => score > 1000,
priority: 5
);
void AddConditionalListener(
UnityAction<TSender, TArgs> call,
Func<TSender, TArgs, bool> condition,
int priority = 0
);
Parameters:
| Name | Type | Description |
|---|---|---|
call | UnityAction<TSender, TArgs> | Callback method |
condition | Func<TSender, TArgs, bool> | Predicate receiving sender and arguments |
priority | int | Execution priority (default: 0) |
Example:
damageEvent.AddConditionalListener(
OnCriticalHit,
(attacker, info) => info.isCritical,
priority: 10
);
RemoveConditionalListener()β
Unregisters a conditional listener.
- GameEvent
- GameEvent<T>
- GameEvent<TSender, TArgs>
void RemoveConditionalListener(UnityAction call);
Parameters:
| Name | Type | Description |
|---|---|---|
call | UnityAction | Callback method with no parameters |
Example:
myEvent.RemoveConditionalListener(OnEventTriggered);
void RemoveConditionalListener(UnityAction<T> call);
Parameters:
| Name | Type | Description |
|---|---|---|
call | UnityAction<T> | Callback method receiving typed argument |
Example:
scoreEvent.RemoveConditionalListener(OnScoreChanged);
void RemoveConditionalListener(UnityAction<TSender, TArgs> call);
Parameters:
| Name | Type | Description |
|---|---|---|
call | UnityAction<TSender, TArgs> | Callback receiving sender and arguments |
Example:
damageEvent.RemoveConditionalListener(OnDamageDealt);
AddPersistentListener()β
Registers a global listener that survives scene changes (DontDestroyOnLoad).
- GameEvent
- GameEvent<T>
- GameEvent<TSender, TArgs>
void AddPersistentListener(UnityAction call, int priority = 0);
Parameters:
| Name | Type | Description |
|---|---|---|
call | UnityAction | Callback method |
priority | int | Execution priority (default: 0) |
Example:
globalEvent.AddPersistentListener(OnGlobalAction, priority: 100);
void AddPersistentListener(UnityAction<T> call, int priority = 0);
Parameters:
| Name | Type | Description |
|---|---|---|
call | UnityAction<T> | Callback method |
priority | int | Execution priority (default: 0) |
void AddPersistentListener(UnityAction<TSender, TArgs> call, int priority = 0);
Parameters:
| Name | Type | Description |
|---|---|---|
call | UnityAction<TSender, TArgs> | Callback method |
priority | int | Execution priority (default: 0) |
Persistent listeners remain active across scene loads. Use for global systems like save management or analytics.
RemovePersistentListener()β
Unregisters a persistent listener.
- GameEvent
- GameEvent<T>
- GameEvent<TSender, TArgs>
void RemovePersistentListener(UnityAction call);
Parameters:
| Name | Type | Description |
|---|---|---|
call | UnityAction | Callback method with no parameters |
Example:
myEvent.RemovePersistentListener(OnEventTriggered);
void RemovePersistentListener(UnityAction<T> call);
Parameters:
| Name | Type | Description |
|---|---|---|
call | UnityAction<T> | Callback method receiving typed argument |
Example:
scoreEvent.RemovePersistentListener(OnScoreChanged);
void RemovePersistentListener(UnityAction<TSender, TArgs> call);
Parameters:
| Name | Type | Description |
|---|---|---|
call | UnityAction<TSender, TArgs> | Callback receiving sender and arguments |
Example:
damageEvent.RemovePersistentListener(OnDamageDealt);
β‘ Trigger Events (Fan-Out Pattern)β
Trigger events enable parallel execution where one event automatically raises multiple target events. All triggers execute independently - if one fails, others continue.
AddTriggerEvent()β
Registers a target event to be triggered automatically when this event is raised.
- GameEvent
- GameEvent<T>
- GameEvent<TSender, TArgs>
TriggerHandle AddTriggerEvent(
GameEventBase targetEvent,
float delay = 0f,
Func<bool> condition = null,
int priority = 0
);
Parameters:
| Name | Type | Description |
|---|---|---|
targetEvent | GameEventBase | The event to trigger |
delay | float | Optional delay in seconds (default: 0) |
condition | Func<bool> | Optional predicate to gate execution |
priority | int | Execution order relative to other triggers (default: 0) |
Returns: TriggerHandle - Unique identifier for safe removal
Example:
// Simple trigger: door opens β light turns on
doorOpenEvent.AddTriggerEvent(lightOnEvent);
// Delayed trigger: explosion after 2 seconds
fuseEvent.AddTriggerEvent(explosionEvent, delay: 2f);
// Conditional trigger
doorOpenEvent.AddTriggerEvent(
alarmEvent,
condition: () => isNightTime
);
// Priority-ordered triggers
bossDefeatedEvent.AddTriggerEvent(stopMusicEvent, priority: 100);
bossDefeatedEvent.AddTriggerEvent(victoryMusicEvent, priority: 90);
bossDefeatedEvent.AddTriggerEvent(showRewardsEvent, priority: 50);
TriggerHandle AddTriggerEvent(
GameEventBase targetEvent,
float delay = 0f,
Func<T, bool> condition = null,
bool passArgument = true,
Func<T, object> argumentTransformer = null,
int priority = 0
);
Parameters:
| Name | Type | Description |
|---|---|---|
targetEvent | GameEventBase | The event to trigger |
delay | float | Optional delay in seconds (default: 0) |
condition | Func<T, bool> | Optional predicate receiving the argument |
passArgument | bool | Whether to pass data to target (default: true) |
argumentTransformer | Func<T, object> | Optional function to transform data |
priority | int | Execution priority (default: 0) |
Returns: TriggerHandle - Unique identifier for safe removal
Example:
// Pass argument directly
GameEvent<int> scoreEvent;
GameEvent<int> updateUIEvent;
scoreEvent.AddTriggerEvent(updateUIEvent, passArgument: true);
// Transform argument: int β string
GameEvent<int> scoreEvent;
GameEvent<string> notificationEvent;
scoreEvent.AddTriggerEvent(
notificationEvent,
passArgument: true,
argumentTransformer: score => $"Score: {score}"
);
// Conditional with argument check
GameEvent<float> healthEvent;
GameEvent lowHealthWarningEvent;
healthEvent.AddTriggerEvent(
lowHealthWarningEvent,
condition: health => health < 20f,
passArgument: false
);
TriggerHandle AddTriggerEvent(
GameEventBase targetEvent,
float delay = 0f,
Func<TSender, TArgs, bool> condition = null,
bool passArgument = true,
Func<TSender, TArgs, object> argumentTransformer = null,
int priority = 0
);
Parameters:
| Name | Type | Description |
|---|---|---|
targetEvent | GameEventBase | The event to trigger |
delay | float | Optional delay in seconds (default: 0) |
condition | Func<TSender, TArgs, bool> | Optional predicate receiving sender and args |
passArgument | bool | Whether to pass data to target (default: true) |
argumentTransformer | Func<TSender, TArgs, object> | Optional transformation function |
priority | int | Execution priority (default: 0) |
Returns: TriggerHandle - Unique identifier for safe removal
Example:
// Pass sender and args to another sender event
GameEvent<GameObject, DamageInfo> damageEvent;
GameEvent<GameObject, DamageInfo> logEvent;
damageEvent.AddTriggerEvent(logEvent, passArgument: true);
// Transform: extract damage value only
GameEvent<GameObject, DamageInfo> damageEvent;
GameEvent<int> damageNumberEvent;
damageEvent.AddTriggerEvent(
damageNumberEvent,
passArgument: true,
argumentTransformer: (sender, info) => info.amount
);
// Conditional based on sender and args
GameEvent<GameObject, DamageInfo> damageEvent;
GameEvent criticalHitEvent;
damageEvent.AddTriggerEvent(
criticalHitEvent,
condition: (sender, info) =>
info.isCritical && sender.CompareTag("Player"),
passArgument: false
);
Triggers execute in parallel - each trigger is independent. If one trigger's condition fails or throws an exception, other triggers still execute.
RemoveTriggerEvent() (by Handle)β
Safely removes a specific trigger using its unique handle.
void RemoveTriggerEvent(TriggerHandle handle);
Parameters:
| Name | Type | Description |
|---|---|---|
handle | TriggerHandle | The handle returned by AddTriggerEvent() |
Example:
TriggerHandle handle = doorEvent.AddTriggerEvent(lightEvent);
// Remove specific trigger
doorEvent.RemoveTriggerEvent(handle);
This is the safest removal method as it only removes your specific trigger instance.
RemoveTriggerEvent() (by Target)β
Removes all triggers pointing to a specific target event.
void RemoveTriggerEvent(GameEventBase targetEvent);
Parameters:
| Name | Type | Description |
|---|---|---|
targetEvent | GameEventBase | The target event to disconnect |
Example:
doorEvent.RemoveTriggerEvent(lightEvent);
This removes ALL triggers targeting this event, including those registered by other systems. Use RemoveTriggerEvent(handle) for precision.
RemoveAllTriggerEvents()β
Removes all trigger events from this event.
void RemoveAllTriggerEvents();
Example:
myEvent.RemoveAllTriggerEvents();
π Chain Events (Sequential Pattern)β
Chain events enable sequential execution where events fire one after another in strict order. Execution stops if any chain node fails.
AddChainEvent()β
Registers a target event to execute sequentially in a chain.
- GameEvent
- GameEvent<T>
- GameEvent<TSender, TArgs>
ChainHandle AddChainEvent(
GameEventBase targetEvent,
float delay = 0f,
float duration = 0f,
Func<bool> condition = null,
bool waitForCompletion = false
);
Parameters:
| Name | Type | Description |
|---|---|---|
targetEvent | GameEventBase | The event to execute in the chain |
delay | float | Delay before executing this node (default: 0) |
duration | float | Delay after executing this node (default: 0) |
condition | Func<bool> | Optional predicate - chain breaks if false |
waitForCompletion | bool | Wait one frame after execution (default: false) |
Returns: ChainHandle - Unique identifier for safe removal
Example:
// Simple sequence: A β B β C
eventA.AddChainEvent(eventB);
eventB.AddChainEvent(eventC);
// Cutscene with delays
fadeOutEvent.AddChainEvent(loadSceneEvent, delay: 1f);
loadSceneEvent.AddChainEvent(fadeInEvent, delay: 0.5f);
// Conditional chain: only continue if condition met
combatEndEvent.AddChainEvent(
victoryEvent,
condition: () => playerHealth > 0
);
// Chain with frame wait for async operations
showDialogEvent.AddChainEvent(
typeTextEvent,
waitForCompletion: true
);
ChainHandle AddChainEvent(
GameEventBase targetEvent,
float delay = 0f,
float duration = 0f,
Func<T, bool> condition = null,
bool passArgument = true,
Func<T, object> argumentTransformer = null,
bool waitForCompletion = false
);
Parameters:
| Name | Type | Description |
|---|---|---|
targetEvent | GameEventBase | The event to execute in the chain |
delay | float | Delay before executing this node (default: 0) |
duration | float | Delay after executing this node (default: 0) |
condition | Func<T, bool> | Optional predicate receiving the argument |
passArgument | bool | Whether to pass data to target (default: true) |
argumentTransformer | Func<T, object> | Optional transformation function |
waitForCompletion | bool | Wait one frame after execution (default: false) |
Returns: ChainHandle - Unique identifier for safe removal
Example:
// Chain with argument passing
GameEvent<int> damageEvent;
GameEvent<int> applyDamageEvent;
GameEvent<int> updateHealthBarEvent;
damageEvent.AddChainEvent(applyDamageEvent, passArgument: true);
applyDamageEvent.AddChainEvent(updateHealthBarEvent, passArgument: true);
// Chain with transformation
GameEvent<int> damageEvent;
GameEvent<float> healthPercentEvent;
damageEvent.AddChainEvent(
healthPercentEvent,
passArgument: true,
argumentTransformer: damage =>
(float)(currentHealth - damage) / maxHealth
);
// Conditional chain with argument check
GameEvent<int> damageEvent;
GameEvent deathEvent;
damageEvent.AddChainEvent(
deathEvent,
condition: damage => (currentHealth - damage) <= 0,
passArgument: false
);
ChainHandle AddChainEvent(
GameEventBase targetEvent,
float delay = 0f,
float duration = 0f,
Func<TSender, TArgs, bool> condition = null,
bool passArgument = true,
Func<TSender, TArgs, object> argumentTransformer = null,
bool waitForCompletion = false
);
Parameters:
| Name | Type | Description |
|---|---|---|
targetEvent | GameEventBase | The event to execute in the chain |
delay | float | Delay before executing this node (default: 0) |
duration | float | Delay after executing this node (default: 0) |
condition | Func<TSender, TArgs, bool> | Optional predicate receiving sender and args |
passArgument | bool | Whether to pass data to target (default: true) |
argumentTransformer | Func<TSender, TArgs, object> | Optional transformation function |
waitForCompletion | bool | Wait one frame after execution (default: false) |
Returns: ChainHandle - Unique identifier for safe removal
Example:
// Attack sequence chain
GameEvent<GameObject, AttackData> attackStartEvent;
GameEvent<GameObject, AttackData> playAnimationEvent;
GameEvent<GameObject, AttackData> dealDamageEvent;
attackStartEvent.AddChainEvent(playAnimationEvent, delay: 0f);
playAnimationEvent.AddChainEvent(dealDamageEvent, delay: 0.5f);
// Extract damage value
GameEvent<GameObject, AttackData> dealDamageEvent;
GameEvent<int> showDamageNumberEvent;
dealDamageEvent.AddChainEvent(
showDamageNumberEvent,
passArgument: true,
argumentTransformer: (attacker, data) => data.damage
);
// Victory chain with condition
GameEvent<GameObject, AttackData> attackEndEvent;
GameEvent<GameObject, VictoryData> victoryEvent;
attackEndEvent.AddChainEvent(
victoryEvent,
condition: (attacker, data) => data.targetHealth <= 0,
argumentTransformer: (attacker, data) =>
new VictoryData { winner = attacker }
);
Chains are sequential (A β B β C). If any node's condition returns false or throws an exception, the entire chain stops at that point.
- Triggers = Parallel (A β [B, C, D]) - all execute independently
- Chains = Sequential (A β B β C) - strict order, stops on failure
RemoveChainEvent() (by Handle)β
Safely removes a specific chain node using its unique handle.
void RemoveChainEvent(ChainHandle handle);
Parameters:
| Name | Type | Description |
|---|---|---|
handle | ChainHandle | The handle returned by AddChainEvent() |
Example:
ChainHandle handle = eventA.AddChainEvent(eventB);
// Remove specific chain node
eventA.RemoveChainEvent(handle);
RemoveChainEvent() (by Target)β
Removes all chain nodes pointing to a specific target event.
void RemoveChainEvent(GameEventBase targetEvent);
Parameters:
| Name | Type | Description |
|---|---|---|
targetEvent | GameEventBase | The target event to disconnect |
Example:
eventA.RemoveChainEvent(eventB);
This removes ALL chain nodes targeting this event. Use RemoveChainEvent(handle) for precision.
RemoveAllChainEvents()β
Removes all chain events from this event.
void RemoveAllChainEvents();
Example:
myEvent.RemoveAllChainEvents();
π§ Configuration & Utilityβ
SetInspectorListenersActive()β
Controls whether Inspector-configured listeners should execute when the event is raised.
void SetInspectorListenersActive(bool isActive);
Parameters:
| Name | Type | Description |
|---|---|---|
isActive | bool | true to enable Inspector listeners, false to mute them |
Example:
// Mute Inspector-configured UI/Audio effects
damageEvent.SetInspectorListenersActive(false);
// Event will only trigger code-registered listeners
damageEvent.Raise(10);
// Re-enable Inspector listeners
damageEvent.SetInspectorListenersActive(true);
Use Cases:
- Temporarily silence visual/audio effects during cutscenes
- Run backend calculations without triggering UI updates
- Disable scene-specific behavior during loading screens
- Simulate game logic in test/debug mode
This setting only affects listeners configured in the Unity Inspector via GameEventManager. Listeners registered via AddListener() in code are not affected and will always execute.
π Quick Reference Tableβ
Method Categoriesβ
| Category | Methods | Purpose |
|---|---|---|
| Execution | Raise(), Cancel() | Trigger events and stop scheduled execution |
| Scheduling | RaiseDelayed(), RaiseRepeating(), CancelDelayed(), CancelRepeating() | Time-based event execution |
| Basic Listeners | AddListener(), RemoveListener(), RemoveAllListeners() | Standard callback registration |
| Priority Listeners | AddPriorityListener(), RemovePriorityListener() | Ordered callback execution |
| Conditional Listeners | AddConditionalListener(), RemoveConditionalListener() | Gated callback execution |
| Persistent Listeners | AddPersistentListener(), RemovePersistentListener() | Scene-independent callbacks |
| Trigger Events | AddTriggerEvent(), RemoveTriggerEvent(), RemoveAllTriggerEvents() | Parallel event chains |
| Chain Events | AddChainEvent(), RemoveChainEvent(), RemoveAllChainEvents() | Sequential event chains |
| Configuration | SetInspectorListenersActive() | Runtime behavior control |
π Supportβ
For additional help:
- Documentation: Full Documentation Site
- Discord: Community Server
- Email: support@yourplugin.com
- GitHub Issues: Report bugs or request features