Skip to main content

Game Event Behavior

Define what happens when an event fires. Unlike traditional events that execute blindly, this system lets you attach conditions, delays, loops, and visual actions directly to the event asset itself.

Game Event Behavior Window


πŸš€ Opening the Behavior Window​

Access from the Game Event Editor:

Game Event Editor β†’ Click Behavior Button (colored pill) on any event row

Button Color States:

ColorIconMeaningDetails
🟒 Greenβœ“Configured (Inspector)Has UnityEvent actions in Manager
πŸ”΅ Blueβ–ΆRuntime Active (Play Mode)Has code-based listeners via AddListener()
🟑 Orange⚠Not ConfiguredNo actions or listeners

Button Label: Shows event type signature (e.g., <void>, <int>, <GameObject, DamageInfo>)


πŸ“‹ Window Overview​

The Behavior Window has four main sections:

  1. Event Information - Identity confirmation (name, category, GUID)
  2. Action Condition - Visual logic tree (execution gate)
  3. Event Action - UnityEvent callbacks (what to execute)
  4. Schedule Configuration - Timing controls (delays, loops, persistence)

1️⃣ Event Information​

Read-only summary confirming you're editing the correct event.

Event Information

Displayed Data:

  • Event Name: Asset name
  • Category: Organizational group
  • GUID: Unique internal identifier (preserved across renames)
Why GUID Matters

The GUID ensures references stay intact even if you rename the event. This is why safe renaming works in the Editor!


2️⃣ Action Condition (Execution Gate)​

The Logic Engine: Actions only execute if these conditions evaluate to TRUE.

Action Condition Section

What It Does​

Controls whether actions execute based on runtime values:

Visual Logic Tree​

Build complex boolean logic without code using:

  • Groups: Combine conditions with AND/OR logic
  • Comparisons: Individual checks (e.g., Health < 20)
  • Nesting: Groups inside groups (unlimited depth)

Performance​

Zero Reflection Overhead

Conditions compile to Expression Trees at initialization. They run as fast as hand-written C# code!

Learn More​

The Visual Condition Tree is a powerful system with many features:

  • 4 Source Types: Event Argument, Scene Type, Random, Constant
  • 10 Comparison Operators: Numeric, String, Collection checks
  • Bool Method Support: Use custom bool methods as conditions
  • Drag & Drop Reordering: Organize logic visually
  • Type Validation: Auto-detects incompatible comparisons

πŸ“– Complete Guide: Visual Condition Tree


3️⃣ Event Action (Callback Layer)​

The Action defines the Unity callbacks that execute once an event is triggered and all conditions are met.

alt text

🧩 Understanding the UnityEvent Field​

The system leverages Unity's native UnityEvent architecture, ensuring seamless integration with your existing MonoBehaviours and UI components.


πŸ”˜ For Parameterless Events (GameEvent)​

Standard trigger-only logic.

TypeBackend FieldCompatibility
LogicUnityEvent (void)🟒 Accepts any zero-parameter method.

Example: OnGameStart βž” AudioManager.PlayBGM(), UI.FadeIn()


πŸ”’ For Single Parameter Events (GameEvent<T>)​

Payload-driven logic. Passes data directly to the listener.

TypeBackend FieldCompatibility
LogicUnityEvent<T>🟑 Accepts methods with one parameter of type T.

Example: OnHealthChanged(float) βž” HealthBar.UpdateFill(float)


πŸ‘₯ For Sender Events (GameEvent<TSender, TArgs>)​

Context-aware logic. Passes both the source and the data payload.

TypeBackend FieldCompatibility
LogicUnityEvent<TSender, TArgs>πŸ”΅ Accepts methods with two parameters.

Example: OnDamage(GameObject, int) βž” VFXManager.SpawnAt(GameObject.pos), Popup.Show(int)

Native Integration

Because we use Native UnityEvents, you can assign listeners directly in the Inspector or via code using AddListener(). It supports both Static and Dynamic calls.

Signature Matching

The inspector UI will automatically filter the method list to only show functions that match the event's signature, preventing runtime errors.


βž• Adding Actions (Workflow)​

alt text

Follow these three simple steps to connect your logic via the Unity Inspector.

1️⃣ Assign Target Object​

Drag and drop the GameObject or Component that contains your logic into the Object slot.

  • πŸ–±οΈ Action: Drag from Hierarchy βž” Drop into the empty slot.
  • πŸ“¦ Result: The field now references the specific instance of your script.

2️⃣ Select Callback Method​

Click the Function Dropdown to browse all public methods available on the assigned object.

  • πŸ” Action: Click No Function βž” Navigate to your Script/Component.
  • ⚑ Tip: Only methods that match the Event Signature (e.g., void, int) will appear at the top for easy selection.

3️⃣ Define Parameter Mapping​

Decide whether to use the event's live data or a fixed value.

  • βš–οΈ Dynamic Call: Uses the runtime value sent by the event (e.g., the actual damage dealt).
  • βš™οΈ Static Parameters: Uses a fixed value you define manually in the Inspector.

πŸ’‘ Dynamic vs. Static: Which one to choose?​

ModeVisual IconBest For...
DynamicπŸš€Real-time data (e.g., Updating a Health Bar with current HP).
StaticπŸ“ŒFixed triggers (e.g., Logging "Button Clicked" to the console).
Pro Tip

In the dropdown, Dynamic methods are always listed at the top of the menu. If you don't see your method there, check if the parameter types match exactly!


Dynamic vs Static Functions​

Dynamic (with event data):

// Receives event parameter(s)
public void TakeDamage(float amount) {
health -= amount;
}

// For Sender events
public void OnDamageReceived(GameObject attacker, DamageInfo info) {
// Use both sender and args
}

Static (ignores event data):

// No parameters needed
public void PlaySound() {
audioSource.Play();
}

When to Use Each:

Use Dynamic WhenUse Static When
You need the event's dataJust need notification
Processing float/int valuesPlaying sounds/effects
Checking sender referenceTriggering animations
Data-driven reactionsState changes

Multiple Actions & Priority​

Add Multiple: Click + repeatedly to add more actions.

Execution Order: Top to bottom.

Reordering: Drag the ☰ handle on the left of each action.

Example:

πŸ“œ LogDamageEvent() βž” 
πŸ₯‡ First (Metadata/Logging)
🎡 PlayHitSound() βž”
πŸ₯ˆ Second (Audio/VFX Feedback)
πŸ“Š UpdateHealthBar(float) βž”
πŸ₯‰ Third (UI/Visual Representation)
🏁 CheckDeathCondition() βž”
πŸ† Final (Game State Logic)

Clear All Actions​

Click "Clear All" button (top-right) to remove all actions at once.

⚠️ Shows confirmation: "Are you sure?"


4️⃣ Schedule Configuration​

The Schedule layer determines when and how often your actions are executed after an event is raised.

alt text

Action Delay​

Time Offset. Introduces a gap between the event trigger and the actual execution.

  • πŸ•’ Value: float (Seconds)
  • 🎯 Purpose: Synchronize with animations, VFX, or delayed game logic.

How It Works:

  1. πŸ”” Event Raised βž” The signal is received.
  2. ⏳ Delaying βž” System waits for the specified X seconds.
  3. πŸ” Condition Check βž” Re-validates conditions after the wait.
  4. πŸš€ Execution βž” Actions fire only if conditions still pass.

❓ Troubleshooting​

Actions Not Executing​

Problem: Event fires but nothing happens.

Checklist:

βœ… Check Conditions:

1. Are conditions enabled? (toggle in condition section)
2. Do conditions evaluate to TRUE?
3. Test condition logic - see Visual Condition Tree guide
4. Add Debug.Log() to verify values

βœ… Check Actions:

1. Is UnityEvent field empty? Add actions!
2. Is target GameObject destroyed?
3. Is target Component disabled?
4. Check Console for errors

βœ… Check Schedule:

1. Is Action Delay too long?
2. Is Repeat Interval causing confusion?
3. Is event Persistent when it shouldn't be?

"Field Not Found" Warning​

Problem: Field 'IntGameEventAction' not found.

Cause: Event type missing its binding code.

Solution:

Click "Force Rebuild All (Fix Missing Bindings)" button.

This regenerates all binding fields:

Assets/TinyGiantsData/GameEventSystem/CodeGen/Basic/
└─ IntGameEvent.cs (regenerated with binding field)

After Compilation: Reopen Behavior Window.


Actions Fire Multiple Times​

Problem: Actions execute more than expected.

Common Causes:

Cause 1: Repeat Settings

Check:
- Repeat Interval > 0?
- Repeat Count > 0?

If yes, event is looping (intentional or accidental)

Cause 2: Multiple Event Raises

Event fires multiple times in code:
OnHealthChanged.Raise(newHealth); ← Called repeatedly

Solution: Ensure event only raises when needed

Cause 3: Multiple Listeners

Same action added multiple times in UnityEvent

Solution: Check action list, remove duplicates

Next Steps

Now that you understand event behaviors, explore the Visual Condition Tree to master advanced conditional logic. Or jump to Flow Editor to build event orchestrations!