Skip to main content

Game Event System

A production-ready, visual event architecture for Unity that transforms chaotic event management into maintainable, testable workflows.

From the Creator

"I built this system because I was tired of battling 'invisible spaghetti code' in my own projects. As an indie developer, I needed a tool that balanced visual clarity with raw coding powerβ€”without performance trade-offs. TinyGiants is my commitment to professional-grade tools that I use in my own games every day." β€” [TinyGiants] from China

Hero Diagram

Why This System Exists​

The Problem

In traditional Unity development, events become invisible spaghetti:

  • Hidden Dependencies: Who's listening? Where's it triggered? Good luck finding out.
  • Runtime Breakage: Rename a method, break 10 scene objects.
  • Cross-Scene Hell: Events die when scenes unloadβ€”memory leaks and null references everywhere.
  • No Visibility: Complex event chains exist only in your head (and outdated comments).
The Solution

TinyGiants.GameEventSystem provides a Visual-First, Type-Safe event architecture:

βœ… Events as Assets - ScriptableObject-based, GUID-protected, survives refactoring

βœ… Visual Flow Graphs - See your event chains, triggers, and conditions in one window

βœ… Zero-Reflection Runtime - Expression Tree compilation for C++-like performance

βœ… Designer-Friendly - Drag-and-drop binding, no coding required for simple workflows

βœ… Production-Grade Tools - Real-time monitoring, reference finding, code generation automation


Core Philosophy: Hybrid Workflow​

This system embraces a division of labor between programmers and designers:

RoleResponsibilityTool
ProgrammerDefine when events fire Raise() and what logic respondsC# API, Listeners
DesignerWire events to scene objects and configure behaviorsInspector Binding, GameEventBehavior
Tech DesignerOrchestrate complex sequences (delays, chains, conditions)Visual Flow Editor

Result: Clean separation of concerns with full visibility into event relationships.


Architecture Highlights​

πŸ—οΈ Foundation: ScriptableObject-Driven​

Unlike string-based or singleton event systems, events are first-class assets:

// Events are assets, not magic strings
[GameEventDropdown] public GameEvent onPlayerDeath;
[GameEventDropdown] public GameEvent<int> onScoreChanged;

void Die() {
onPlayerDeath.Raise(); // Type-safe, asset-referenced
}

Benefits:

  • βœ… Complete Decoupling - Senders never know receivers. Fire once, notify many.
  • βœ… Cross-Scene Persistence - Events survive scene loads/unloads.
  • βœ… GUID Identity - Rename files, reorganize foldersβ€”references never break.
  • βœ… Multi-Database Support - Modular organization for large teams.
πŸ“– How GUID Protection Works

Every event has a unique GUID stored in .meta files:

# PlayerDeath.asset.meta
guid: a7f3c21e9b4d8f6e2d1a9c8b7e6f5a4d

Even if you rename PlayerDeath OnCharacterDied, Unity maintains the reference via GUID. No broken scene links.


πŸ•ΈοΈ Visual Flow Orchestration​

Stop hunting through code to understand event relationships. The Flow Editor turns invisible logic into maintainable graphs:

Use Cases​

🎯 Triggers (Fan-Out)

alt text

⛓️ Chains (Sequential)

alt text

πŸ”€ Hybrid Flows

Mix parallel + sequential logic

alt text

Visual Benefits
  • Group Organization - Color-coded groups for large flows
  • Real-Time Validation - Connection type checking (Green=Valid, Red=Error)
  • Undo/Redo Support - Full history system (Ctrl+Z/Y)
  • Runtime Debugging - Active nodes highlight in Play Mode

⚑ Type-Safe, Zero-Reflection Performance​

Unity's generic serialization is broken by design. I fixed it.

The Problem​

// ❌ Unity can't serialize this
[SerializeField] private GameEvent<PlayerData> onPlayerDataChanged;

Our Solution​

// βœ… Auto-generated concrete class
[GameEventDropdown] public PlayerDataGameEvent onPlayerDataChanged;

// Generated code (automatic):
[Serializable]
public class PlayerDataGameEvent : GameEvent<PlayerData> { }

Performance Benefits:

  • πŸš€ Expression Tree Compilation - Conditions compile to delegates at startup (no runtime parsing)
  • πŸš€ No Reflection Cost - Direct method calls, not Invoke()
  • πŸš€ Native Inspector Support - Full UnityEvent<T> compatibility
βš™οΈ Code Generation Workflow
  1. Select Types - Choose your custom types in the Creator window
  2. Generate - Click "Generate" to create concrete classes
  3. Compile - Unity auto-compiles the new code
  4. Create - Now you can create events for your custom types

Time investment: ~30 seconds. Benefit: Lifetime type safety.


Feature Matrix​

βš“ Core Architecture​

FeatureDescription
Asset-Based EventsScriptableObject architecture with GUID Identityβ€”references survive renames and file moves.
Comprehensive GenericsNative support for GaneEvent<Void>, GameEvent<T>, and source-aware GameEvent<TSender, TArgs>.
Multi-Database SystemModular organization supporting multiple databases with Dynamic Loading and Health Checks.
Category SystemString-based categorization for efficient fuzzy-search filtering within large event libraries.
Auto Static ResetAutomatic clearing of static caches in Editor Play Mode to prevent data pollution.

🧠 Advanced Logic & Flow​

FeatureDescription
Expression TreesZero-reflection logic evaluation; conditions are compiled into high-performance delegates at runtime.
Visual Logic BuilderConstruct complex nested AND/OR logic and dynamic property comparisons without code.
Hybrid ExecutionSeamlessly mix parallel Fan-out Triggers and sequential Blocking Chains in one graph.
Argument TransformersDynamically extract and pass specific object properties as arguments between flow nodes.
Granular Flow ControlPer-node delays, Async/Coroutine waits, loop counts, and conditional execution gates.

🎧 Listening & Binding​

FeatureDescription
Visual BindingDrag-and-drop UnityEvent wiring in the Inspector with visual status markers and type safety.
Priority ListenersInteger-based sorting ensuring critical systems react before standard UI/Audio listeners.
Conditional ListenersBuilt-in Predicate supportβ€”callbacks only fire when specific logical criteria are met.
Persistent ListenersNative support for cross-scene listeners that remain active during scene transitions.
Dynamic Runtime APIFull programmatic control to register or unregister listeners and manage Task Handles.

πŸ“Š Tooling & Debug​

FeatureDescription
Dashboard & WizardModern UI for Batch Operations and a fuzzy-matching Wizard for rapid event creation.
Code AutomationTri-Mode CodeGen (Basic/Custom/Sender) with automatic compilation pipeline integration.
Reference FinderScene-wide scanner to pinpoint exactly which components reference specific event assets.
Runtime MonitorReal-time profiling of Execution Time (Avg/Min/Max), listener counts, and GC allocation.
Automation TreeReal-time visualizer for active Trigger and Chain hierarchies to debug complex logic flows.

Performance Characteristics​

Real-world metrics from production builds:

ScenarioPerformanceNotes
Event Raise (0 listeners)~0.001msVirtually free
Event Raise (10 listeners)~0.02msNo GC allocation
Condition Evaluation~0.003msExpression Tree compilation
Flow Node Execution~0.05msIncludes coroutine overhead
Monitor Window (100 events)~0.3msEditor-only, no runtime cost
Production Ready

Tested in shipped titles with 500+ events and 10,000+ listeners across scenes. Zero performance regressions.


πŸ—ΊοΈ Navigation Roadmap​

This map provides a complete overview of the system documentation. Use the tables below to quickly jump to the specific feature or tutorial you need.

Recommended Learning Paths

🏁 1. Introduction​

Foundational setup and core philosophy of the event-as-asset architecture.

PageDescription
Project StructureUnderstanding directory layout, folder protection, and modular organization.
InstallationInitializing the plugin and setting up the automated static reset pipeline.

πŸ’Ž 2. Visual Workflow​

Management tools designed to transform invisible code into a tangible visual dashboard.

PageDescription
System DashboardOverview of the asset-based workflow and GUID identity system
Database & FlowGraphHandling multi-database and multi-flowgraph setups and database health maintenance
Edit Game EventUsing the Dashboard for batch editing, search, and categorization
Create Game EventRapidly generating event assets using the fuzzy-search batch wizard
Configure Game EventMastering Inspector binding with visual status markers and type safety
Raise Game EventLearn how to call events and enhance inspectors using the built-in GameEventDropdown Attribute
Find Game EventScanning scenes to locate component-level event dependencies.
Visual Condition TreeLearn how to control the logic execution of event action through condition tree configuration

πŸ•ΈοΈ 3. Flow Orchestration​

Visualizing and building complex multi-step logic sequences using nodes.

PageDescription
Node EditorManaging the GraphView canvas, groups, and snapshot-based Undo/Redo
Node ConnectorRules for hybrid execution modes and real-time connection validation
Node BehaviorConfiguring node-level delays, loops, and argument transformation logic
Advanced Logic PatternsBuilding no-code nested logic groups and conditional execution gates

πŸ’» 4. Scripting & API​

The developer's guide to high-performance C# integration and lifecycle management.

PageDescription
Raising & SchedulingProgrammatic firing, delayed execution, and Task Handle management
Listening Strategiesimplementing prioritized, persistent, and source-aware (Sender) listeners
Programmatic FlowUsing Expression Tree-based predicates for zero-reflection logic filtering
Best PracticesArchitectural tips for clean decoupling and preventing data pollution
API ReferenceDetailed technical documentation for all core classes and attributes

πŸ› οΈ 5. Tools & Support​

Automation and monitoring utilities for professional production environments.

PageDescription
CodeGen & CleanupUsing the Tri-Mode Generator and compilation pipeline automation
Runtime MonitorReal-time performance profiling, deep logging, and warning systems
Community & SupportAccessing updates, reporting bugs, and getting technical assistance

πŸ“š 6. Examples​

Practical, ready-to-use scenes covering every scenario from basics to advanced API usage.

IDExample PageKey Learning Point
00Quick StartThe minimal workflow for creating, raising, and binding an event
01Void EventUsing parameterless signals for global triggers like "Level Start"
02Basic Types EventPassing primitive data (int, float, string) through events
03Custom Type EventLeveraging CodeGen for serialized custom data classes and structs
04Custom Sender EventUsing source-aware events to identify which entity raised the signal
05Priority EventPrecisely controlling the execution order of multiple listeners
06Conditional EventUsing predicates to execute callbacks only when criteria are met
07Delayed EventManaging timed logic and using Task Handles for cancellation
08Repeating EventCreating recurring pulse signals and automated logic loops
09Persistent EventHandling events during scene transitions (DontDestroyOnLoad)
10Trigger EventBridging Unity's Physics system with Game Event assets
11Chain EventBuilding visual sequential logic using the Flow Orchestration graph
12Multi DatabaseIsolating events into different assets for modular project organization
13Runtime APIRegistering and unregistering listeners dynamically via C# scripts
14Runtime MonitorUsing profiling tools to debug execution timing and GC allocations
Navigational Tip

For a hands-on start, we recommend following Example 00 (Quick Start) first, then exploring the Visual Workflow section to see how the editor tools can streamline your development.