A type-safe data pipeline for game development that converts JSON entity definitions into Unity C# classes.
This OCaml-based tool processes JSON game data files (weapons, characters, skills, etc.) and generates corresponding C# classes for Unity, while validating entity relationships and ensuring data integrity.
Input: JSON entity definitions → Output: Unity C# classes + validation
# Setup (requires OCaml 5.2.0+)
opam switch create . 5.2.0
eval $(opam env --set-switch)
opam install . --deps-only
# Configure paths (edit fey-data.config as needed)
# Example: change game_root = "../fey-game-mock" for public demo project
# Run the pipeline
dune exec gamedata
# Development mode (auto-rebuild on changes)
fish watch.fishJSON Files → Validation → Entity Processing → C# Generation → Unity Assets
-
JSON Input: Game entities in
../Assets/StreamingAssets/json/- Format:
<name>.<type>.json(e.g.,sword.weapon.json) - Types: weapon, character, skill, equipment, audio, animation, etc.
- Format:
-
Validation: Ensures data integrity
- Schema validation
- Cross-reference checking
- Type safety
-
C# Generation: Creates Unity-compatible classes
- Output:
../Assets/Scripts/Octoio/Fey/Data/Dto/ - Includes
[Serializable]attributes - Generates entity reference indices
- Output:
├── lib/ # Core OCaml modules
│ ├── config/ # Configuration constants
│ │ └── constants.ml # Config.Constants.*
│ ├── data/ # Entity type definitions
│ │ ├── *.atd # Entity type schemas
│ │ ├── entity_util.ml # Data.Entity_util.*
│ │ └── validation.ml # Data.Validation.*
│ ├── util/ # Generic utilities
│ │ ├── string.ml # Util.String.*
│ │ └── entity.ml # (placeholder)
│ ├── csharp/ # C# code generation
│ ├── processing.ml # Main pipeline orchestrator
│ ├── dataset.ml # Data management
│ ├── validate.ml # Validation logic
│ ├── io.ml # File operations
│ └── server.ml # Web interface
├── bin/ # Executables
├── test/ # Comprehensive test suite
├── fey-data.config # Configuration file for paths
├── watch.fish # Development file watcher
└── test.fish # Test runner
The codebase follows a clean modular architecture:
Config.Constants.*- Configuration paths and settingsData.*- Entity types, validation, and utilitiesUtil.*- Generic utility functionsGamedata.*- Core processing and pipeline logic
The fey-data.config file allows customization of input/output paths:
# Game project root (change to ../fey-game-mock for public demo)
game_root = "../fey"
# StreamingAssets folder location
streaming_assets_path = "Assets/StreamingAssets"
# JSON data subfolder
json_path = "json"
# C# output location
scripts_path = "Assets/Scripts/Octoio/Fey/Data/Dto"
Supports various game entity types including:
- Combat: weapon, character, skill, equipment, status
- Assets: audio, animation, model, image, cursor
- System: quality, stat, drop, affix, requirement
Each type has its own ATD schema defining structure and validation rules.
- Type Safety: OCaml's type system ensures correctness
- Modular Architecture: Clean separation of concerns
- Validation: Comprehensive error checking and reporting
- Hot Reload: File watcher for immediate feedback
- Unity Integration: Generated C# classes with proper attributes
- Entity References: Validates cross-entity relationships
- Performance: Efficient indexing and hashing
# Run all tests
dune runtest
# Comprehensive test suite with setup
fish test.fish
# With coverage
dune runtest --instrument-with bisect_ppxTest Coverage: Comprehensive tests across multiple test modules covering all core functionality.
See LICENSE file for details.