This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
UnityAccessibilityLib is a C# library that adds screen reader accessibility to Unity games. It works with any Unity mod framework (MelonLoader, BepInEx, etc.) and provides speech and braille output, text cleaning utilities, and P/Invoke wrappers for UniversalSpeech with SAPI fallback.
# Build all target frameworks (net6.0, net472, net35)
dotnet build
# Build specific framework
dotnet build -f net6.0
dotnet build -f net472
dotnet build -f net35
# Release build
dotnet build -c Release
# Create NuGet package
dotnet pack -c ReleaseBuild outputs are located at bin/{Debug|Release}/{net6.0|net472|net35}/UnityAccessibilityLib.dll.
To publish a new version to NuGet:
-
Bump the version in
UnityAccessibilityLib.csproj:<Version>1.1.0</Version>
-
Commit and tag the release:
git add UnityAccessibilityLib.csproj git commit -m "chore: Bump version to 1.1.0" git tag v1.1.0 -
Push the tag to trigger the GitHub Actions workflow:
git push origin master git push origin v1.1.0
The v* tag push triggers the .github/workflows/nuget-publish.yml workflow, which builds and publishes the package to NuGet automatically.
No test framework is currently configured. If adding tests, use standard dotnet test commands.
- SpeechManager (
SpeechManager.cs): High-level static API for speech and braille output with duplicate prevention, repeat functionality, and text formatting - UniversalSpeechWrapper (
UniversalSpeechWrapper.cs): Low-level P/Invoke wrapper for UniversalSpeech.dll with SAPI fallback; providesSpeak()andDisplayBraille()methods - TextCleaner (
TextCleaner.cs): Removes Unity rich text tags and normalizes text; supports custom string and regex replacements viaAddReplacement()andAddRegexReplacement() - AccessibilityLog/IAccessibilityLogger (
IAccessibilityLogger.cs): Logging facade with pluggable logger interface - Net35Extensions (
Net35Extensions.cs): Polyfills for .NET 3.5 compatibility (e.g.,IsNullOrWhiteSpace)
Consumer (MelonMod, BepInEx Plugin, etc.)
│
├─ Sets AccessibilityLog.Logger
├─ Calls SpeechManager.Initialize()
└─ Calls SpeechManager.Output()
│
├─ Duplicate suppression (time-based)
├─ TextCleaner.Clean() (strips rich text, applies custom replacements)
├─ UniversalSpeechWrapper.Speak() (P/Invoke)
└─ UniversalSpeechWrapper.DisplayBraille() (if EnableBraille)
- Custom Logger: Implement
IAccessibilityLoggerinterface - Text Formatting: Set
SpeechManager.FormatTextOverridedelegate - Repeat Logic: Set
SpeechManager.ShouldStoreForRepeatPredicatedelegate - Custom Text Types: Use constants starting from
TextType.CustomBase(100) - Text Cleaning: Use
TextCleaner.AddReplacement()andTextCleaner.AddRegexReplacement()for custom text transformations - Braille Control: Set
SpeechManager.EnableBrailleto toggle braille output (default: true)
- All public classes are static (no instance creation)
- Private fields use
_camelCaseprefix - P/Invoke constants use
ALL_CAPS - Single namespace:
UnityAccessibilityLib - Comprehensive XML documentation on all public members
- Multi-target build: net35 is limited to C# 7.3 features
- Windows only (P/Invoke and SAPI are Windows-specific)
- UniversalSpeech.dll must be deployed alongside consuming mod
- Supports screen readers: NVDA, JAWS, Window-Eyes, System Access, Supernova, ZoomText