This guide will help you set up the development environment to build and modify the accessibility mod.
- Visual Studio 2022 or JetBrains Rider or VS Code with C# extension
- .NET 6.0 SDK or higher (Download)
- The Drifter Game (Steam or GOG version)
- MelonLoader installed in the game (Download)
- Git (optional, for version control)
Make sure The Drifter is installed and MelonLoader is set up:
[Game Folder]\
├── TheDrifter.exe
├── TheDrifter_Data\
│ └── Managed\
│ ├── Assembly-CSharp.dll
│ ├── UnityEngine.dll
│ ├── UnityEngine.CoreModule.dll
│ └── [other Unity DLLs]
├── MelonLoader\
│ ├── MelonLoader.dll
│ ├── 0Harmony.dll
│ └── [other MelonLoader files]
└── Mods\
└── [empty initially]
The .csproj file contains hardcoded paths that need to be updated to match your installation:
-
Open
TheDrifterAccessibility.csprojin a text editor -
Find all
<Reference>tags and update the<HintPath>to point to your game installation -
Update these paths (example for Steam installation):
<!-- MelonLoader -->
<Reference Include="MelonLoader">
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\The Drifter\MelonLoader\MelonLoader.dll</HintPath>
<Private>False</Private>
</Reference>
<!-- Unity Engine -->
<Reference Include="UnityEngine">
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\The Drifter\MelonLoader\Managed\UnityEngine.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\The Drifter\TheDrifter_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
<Private>False</Private>
</Reference>
<!-- Continue for all references... -->Common Installation Paths:
- Steam:
C:\Program Files (x86)\Steam\steamapps\common\The Drifter\ - GOG:
C:\GOG Games\The Drifter\ - Epic Games:
C:\Program Files\Epic Games\The Drifter\
Create an environment variable DRIFTER_PATH pointing to your game folder:
setx DRIFTER_PATH "C:\Program Files (x86)\Steam\steamapps\common\The Drifter"Then update .csproj to use:
<Reference Include="MelonLoader">
<HintPath>$(DRIFTER_PATH)\MelonLoader\MelonLoader.dll</HintPath>
<Private>False</Private>
</Reference>cd "E:\Game codes\The Drifter\TheDrifterAccessibility"
dotnet restore
dotnet build -c ReleaseOutput will be in: bin\Release\net6.0\TheDrifterAccessibility.dll
- Open
TheDrifterAccessibility.csprojin Visual Studio - Build → Build Solution (F6)
- Or right-click project → Build
After updating paths in build.bat:
cd "E:\Game codes\The Drifter\TheDrifterAccessibility"
build.batThe script will:
- Clean previous builds
- Compile the DLL
- Copy to game's Mods folder
- Copy dependencies to game folder
TheDrifterAccessibility\
├── Core\
│ ├── AccessibilityManager.cs # Main TTS coordinator
│ └── KeyboardNavigationHandler.cs # Keyboard input handler
├── ScreenReader\
│ ├── TolkWrapper.cs # TOLK library wrapper
│ └── NVDAWrapper.cs # NVDA direct wrapper
├── Patches\
│ ├── QuestTextPatches.cs # Core text display patches
│ ├── DialogPatches.cs # Dialog system patches
│ ├── GuiComponentPatches.cs # UI component patches
│ ├── HotspotPatches.cs # World object patches
│ ├── InventoryPatches.cs # Inventory system patches
│ └── MenuPatches.cs # Menu system patches
├── Properties\
│ └── AssemblyInfo.cs # Assembly metadata
├── TheDrifterAccessibilityMod.cs # Main mod entry point
├── TheDrifterAccessibility.csproj # Project file
├── build.bat # Build script
├── README.md # User documentation
├── INSTALLATION.md # Installation guide
├── DEVELOPER_SETUP.md # This file
└── CHANGELOG.md # Version history
- Edit source files in your IDE
- Build the project (Ctrl+Shift+B in VS)
- The DLL is automatically copied to Mods folder (if build script is used)
- Launch The Drifter
- MelonLoader console will show mod loading
- Check
MelonLoader\Latest.logfor errors - Test with a screen reader (NVDA recommended)
Enable MelonLoader Debug Mode:
- Open
MelonLoader\MelonLoader.cfg - Set
Debug = true - Relaunch game
View Logs:
- Real-time: Watch
MelonLoader\Latest.log - Use
MelonLogger.Msg()for debug output - Use
MelonLogger.Error()for errors
Attach Debugger:
- Visual Studio → Debug → Attach to Process
- Find
TheDrifter.exe - Set breakpoints in your code
- Trigger the code in-game
The mod uses Harmony to inject code into game methods:
[HarmonyPatch(typeof(Button))] // Target class
public static class ButtonPatches
{
[HarmonyPatch(nameof(Button.Click))] // Target method
[HarmonyPrefix] // Run before original
public static void Click_Prefix(Button __instance)
{
// Your code here
// __instance is the Button being clicked
}
}Patch Types:
[HarmonyPrefix]- Runs before the original method[HarmonyPostfix]- Runs after the original method[HarmonyTranspiler]- Modifies IL code (advanced)
Central coordinator for all TTS:
var manager = AccessibilityManager.Instance;
manager.Speak("Hello world", interrupt: true);
manager.AnnounceButton("Play Game", enabled: true);
manager.AnnounceDialog("Annie", "How are you?");// Initialize
TolkWrapper.Initialize();
// Speak
TolkWrapper.Output("Text to speak", interrupt: false);
// Check status
bool isActive = TolkWrapper.IsActive;
// Shutdown
TolkWrapper.Shutdown();-
Find the Game Class: Use dnSpy or ILSpy to find the class name
-
Create a Patch:
[HarmonyPatch(typeof(NewGuiElement))]
public static class NewGuiElementPatches
{
[HarmonyPatch("OnShow")]
[HarmonyPostfix]
public static void OnShow_Postfix(NewGuiElement __instance)
{
var manager = AccessibilityManager.Instance;
if (!manager.IsScreenReaderActive())
return;
string text = __instance.GetText();
manager.Speak(text, true);
}
}- Register the Patch in
TheDrifterAccessibilityMod.cs:
typeof(NewGuiElementPatches),- Build and Test
Solution: Update paths in .csproj to match your installation
Solution:
- Check class and method names match exactly
- Verify namespace imports
- Check MelonLoader log for patch errors
Solution:
- Ensure screen reader is running
- Press F2 to toggle accessibility
- Check
TolkWrapper.Initialize()succeeded
Solution:
- Verify MelonLoader is installed
- Check MelonLoader version compatibility
- Look for errors in
MelonLoader\Latest.log
- Main menu buttons announced
- Dialog text read with character names
- Hotspots announced on hover
- Inventory items announced
- Dialog choices navigable with arrow keys
- F1-F10 hotkeys work
- Settings changes announced
- Scene transitions announced
- No crashes or errors in log
- Performance is acceptable
- Use C# naming conventions (PascalCase for public, camelCase for private)
- Add XML documentation to public methods
- Keep methods focused and small
- Handle exceptions gracefully
- Log errors with
MelonLogger.Error()
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly with a screen reader
- Update CHANGELOG.md
- Submit pull request with description
- dnSpy: Decompile and debug Unity games (Download)
- ILSpy: View .NET assemblies (Download)
- UnityExplorer: Runtime Unity inspector for MelonLoader (GitHub)
- MelonLoader Discord: https://discord.gg/2Wn3N2P
- Unity Modding Discord: https://discord.gg/...
- Accessibility Gaming: https://discord.gg/...
MIT License - See main README.md for full text
Happy modding! 🔧♿