Skip to content

Latest commit

 

History

History
37 lines (27 loc) · 1.58 KB

File metadata and controls

37 lines (27 loc) · 1.58 KB

Chain of Responsibility Pattern Example

A Unity example demonstrating the Chain of Responsibility pattern with a game input handling system.

Overview

The Chain of Responsibility pattern manages input handling across different game states (gameplay, UI, cutscenes, dialog). Each handler processes input based on the current game state, ensuring inputs are handled appropriately in each context.

Implementation

Usage

// Setup is automatic - just add to a GameObject
InputManager manager = gameObject.AddComponent<InputManager>();

// Change states as needed
manager.SetGameState(InputState.Dialog);    // When entering dialog
manager.SetGameState(InputState.Gameplay);  // When returning to gameplay

Benefits

  • Clean separation of input handling by game state
  • Easy to add new input states and handlers
  • Prevents input conflicts between states
  • Centralized input management