Skip to content

UlgenKhan/DialogueSystem

Repository files navigation

Dialogue System (Unity)
This is a robust, node-based dialogue system designed for Unity, utilizing the NodeGraphProcessor library for visual graph editing. The system enables complex, branching narratives with state persistence, event triggers, and optimized UI handling.
See the Documentation
Features

  • Node-Based Architecture: Create branching narrative paths using a visual graph interface.
  • State & Variable Management: Real-time tracking of gameplay variables (player stats, relationship levels) via a centralized VariableManager.
  • Event-Driven: Trigger custom game events directly from the dialogue graph using ScriptableObject-based events.
  • Performance-Optimized UI: Implements an object pool for dialogue choices, preventing unnecessary instantiation overhead during gameplay.
  • Persistent History: Automatically saves and loads choice history, ensuring player decisions persist across sessions.
  • Dynamic Feedback: Options use a selectedBefore flag to provide visual feedback (e.g., graying out previously chosen options).
    Quick Setup
    Follow these steps to integrate the system into your scene:
    1. Scene Components
  • VariableManager: Create an empty GameObject, attach the VariableManager script, and define your global variables (key-value pairs) in the inspector.
  • DialogueRunner: Attach the DialogueRunner script to your scene. Configure it by dragging the required references:
    • Graph: Assign your BaseGraph asset.
    • Variable Manager: Link the instance created above.
    • UI References: Connect your Dialogue Box, TextMeshPro components (Npc Text, Npc Name Text), and the DialogueOption prefab located in your Prefabs folder.
    • Options Container: Assign a RectTransform (e.g., a Vertical Layout Group) to manage the layout of dialogue choices.
      Architecture Overview
  • Data Models: Characters and Factions are defined as ScriptableObjects, allowing for modular and easy-to-manage narrative data.
  • Object Pooling: To ensure optimal performance, the GetOrCreateOption() method efficiently reuses existing DialogueOption instances rather than creating new ones on each dialogue step.
  • Dynamic Text: You can include variable placeholders in dialogue (e.g., {PlayerName}), which are dynamically resolved at runtime using the VariableManager.
    Requirements
  • NodeGraphProcessor must be installed in your Unity project.
  • TextMeshPro must be imported into the project.
    License
    This project is available for viewing and evaluation purposes only. See the LICENSE file for details.
     

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors