Advanced C# to C++ Transpiler v3.0
Tool made by Mr.Croft
A powerful Unity Editor tool that converts C# MonoBehaviour scripts into production-ready (or at least 80% of it) C++ code for SEGA Dreamcast development. This transpiler bridges the gap between modern Unity development and retro Dreamcast homebrew programming.
This transpiler is specifically designed for developers porting Unity games to the SEGA Dreamcast. It provides two conversion modes:
- Advanced Parser Mode (v2.1) - Fast, Dreamcast-optimized, lightweight regex-based conversion
- IL2CPP Backend Mode (v3.0) - Unity's official IL2CPP compiler for production-grade, semantically accurate C++ output
- โ Complete Class Conversion - Converts MonoBehaviour, Component, ScriptableObject, and regular classes
- โ Method Translation - Translates methods with full parameter support and return types
- โ Field & Property Mapping - Converts fields, properties (getters/setters), and automatic properties
- โ Unity Lifecycle Support - Handles Awake, Start, Update, FixedUpdate, OnDestroy, OnCollisionEnter, etc.
- โ
Type Mapping - Automatic conversion of Unity types to Dreamcast equivalents
Vector3โvec3_tGameObjectโgame_object_t*Transformโtransform_t*Rigidbodyโrigidbody_t*- And 60+ more type mappings
- โ
Unity API Translation - Converts common Unity APIs to Dreamcast equivalents
Time.deltaTimeโdeltaTimeDebug.Log()โdebug_log()Vector3.zeroโvec3_zero()Physics.Raycast()โphysics_raycast()- And 50+ more API mappings
- ๐ Nested Classes & Structs - Preserves nested type definitions
- ๐ฒ Enum Support - Converts C# enums to C++ enum classes
- ๐ Coroutine Detection - Identifies coroutine patterns (requires manual implementation)
- ๐ฎ Input System Support - Handles Unity's new Input System (InputAction, PlayerControls, etc.)
- ๐ Component References - Converts GetComponent() patterns
- โก Performance Optimizations - Dreamcast-specific code generation
- ๐ Code Documentation - Generates warnings and TODO lists for manual review
- ๐จ Clean Editor Window - Integrated Unity Editor GUI
- ๐ Drag & Drop - Simple MonoScript selection
- ๐พ Export Options - Save header (.h) and implementation (.cpp) files
- ๐ Multi-Tab View - Separate tabs for Header, Implementation, Warnings, and TODOs
- ๐ Real-time Conversion - Instant feedback on code conversion
- ๐ Copy to Clipboard - Quick copy buttons for all outputs
-
AdvancedCppConverter.cs (~700 lines)
- Main conversion engine
- Type mapping dictionary (typeMap)
- Unity API mapping (unityApiMap)
- Header and implementation generation
-
CppConverterParsing.cs (~400 lines)
- Parsing utilities
- Field/method/property extraction
- Line-by-line code conversion
- Syntax transformation helpers
-
IL2CPPIntegration.cs (~300 lines)
- Unity IL2CPP backend integration
- Process management for il2cpp.exe
- Generated code extraction
- Error handling and diagnostics
-
CSharpToCppTranspiler.cs (~200 lines)
- Original Advanced Parser GUI (v2.1)
- Menu:
Dreamcast > Advanced C# to C++ Transpiler
-
HybridCppTranspiler.cs (~350 lines)
- Hybrid mode GUI with IL2CPP support (v3.0)
- Menu:
Dreamcast > Hybrid C# to C++ Transpiler v3.0
- Unity 6000.1 or newer (tested on Unity 6000.1)
- Windows, macOS, or Linux
- IL2CPP build support (optional, for IL2CPP mode)
-
Copy the folder
Place theCSharp2CPPfolder inside your Unity project:/Assets/DreamcastBridge/Dreamcast/Editor/CSharp2CPP/ -
Wait for compilation
Unity will automatically compile the scripts. -
Verify installation
Check for new menu items:Dreamcast > Advanced C# to C++ TranspilerDreamcast > Hybrid C# to C++ Transpiler v3.0
-
Open the transpiler
- Go to
Window > Dreamcast > Hybrid C# to C++ Transpiler v3.0
- Go to
-
Select your C# script
- Drag & drop a MonoScript into the "C# Script" field
- Or click the field to browse
-
Choose conversion mode
- Advanced Parser - For Dreamcast-optimized, lightweight output
- IL2CPP Backend - For Unity-accurate, production code
-
Convert
- Click "Convert with Advanced Parser" or "Convert with IL2CPP"
- Wait for conversion to complete
-
Review output
- Check the Header tab for the .h file
- Check the Implementation tab for the .cpp file
- Review Warnings for potential issues
- Check TODOs for manual implementation tasks
-
Export
- Click "Save Header (.h)" and "Save Implementation (.cpp)"
- Choose destination folder
- Files are ready for Dreamcast compilation!
Best for: Final Dreamcast builds, memory-constrained environments
Characteristics:
- โ Fast conversion (~1-2 seconds)
- โ Dreamcast-optimized code
- โ Minimal memory footprint
- โ No external dependencies
- โ Direct C++ output
โ ๏ธ May require manual fixes for complex logic
When to use:
- You need compact, Dreamcast-ready code
- Memory is critical (Dreamcast has 16MB RAM)
- You want full control over the C++ output
- You're willing to manually implement complex features
Example output:
// Header (.h)
struct player_controller_t : public component_t
{
float moveSpeed;
vec3_t velocity;
void move(vec3_t direction);
void jump();
};
// Implementation (.cpp)
void player_controller_t::move(vec3_t direction)
{
velocity = vec3_scale(direction, moveSpeed);
}Best for: Reference code, understanding Unity semantics, testing
Characteristics:
- โ Unity-accurate conversion
- โ Production-grade C++ output
- โ Handles complex C# features
- โ Complete Unity API mapping
- โ Requires libil2cpp runtime (~30MB)
- โ Not practical for Dreamcast (16MB RAM limit)
When to use:
- You need to understand how Unity handles complex code
- You want reference implementations for manual porting
- You're testing conversion accuracy
- You're developing for other platforms first
Example output:
// IL2CPP generates complete Unity runtime code
// with all safety checks, metadata, and runtime features
// Great for reference, but too large for DreamcastFor best results, use both modes together:
-
Start with IL2CPP (Reference)
- Convert your script with IL2CPP mode
- Study the generated code
- Understand Unity's implementation of complex features
-
Implement with Advanced Parser (Production)
- Convert the same script with Advanced Parser
- Use IL2CPP output as reference for manual fixes
- Optimize for Dreamcast constraints
- Test on hardware
-
Iterate
- Refine the C++ code
- Add Dreamcast-specific optimizations
- Remove unnecessary Unity abstractions
โ
Class structure and hierarchy
โ
Field and property declarations
โ
Method signatures and basic logic
โ
Type conversions
โ
Unity lifecycle method detection
โ
Basic API mappings
โ Unity Runtime - You must implement the Dreamcast equivalents:
game_object_t,transform_t,component_tstructures- Physics system (
rigidbody_t, collision detection) - Input handling (
input_action_t, controller support) - Rendering system (mesh, materials, textures)
โ Complex Logic - Advanced C# features may need manual porting:
- Coroutines (requires state machine implementation)
- LINQ queries (convert to loops)
- Lambda expressions (convert to function pointers)
- Events and delegates (implement callback systems)
- Reflection (not supported on Dreamcast)
โ Platform-Specific Code - Dreamcast has unique constraints:
- Memory management (16MB RAM total)
- VMU (Visual Memory Unit) integration
- Controller vibration (jump pack)
- Network play (modem/broadband adapter)
| C# Type | C++ Type |
|---|---|
int |
int32_t |
float |
float |
bool |
bool |
string |
std::string |
void |
void |
| C# Type | Dreamcast C++ Type |
|---|---|
Vector2 |
vec2_t |
Vector3 |
vec3_t |
Vector4 |
vec4_t |
Quaternion |
quat_t |
Color |
color_t |
Matrix4x4 |
matrix4x4_t |
| C# Type | Dreamcast C++ Type |
|---|---|
GameObject |
game_object_t* |
Transform |
transform_t* |
Rigidbody |
rigidbody_t* |
Collider |
collider_t* |
CharacterController |
character_controller_t* |
AudioSource |
audio_source_t* |
Camera |
camera_t* |
| C# API | Dreamcast C++ API |
|---|---|
Time.deltaTime |
deltaTime |
Debug.Log() |
debug_log() |
Vector3.zero |
vec3_zero() |
Physics.Raycast() |
physics_raycast() |
Input.GetKey() |
is_key_down() |
Instantiate() |
instantiate_game_object() |
Destroy() |
destroy_game_object() |
Solution:
- Install IL2CPP build support in Unity Hub
- Verify installation path in transpiler warnings
- Use Advanced Parser mode as fallback
Solution:
- Check C# script for syntax errors
- Ensure script compiles in Unity first
- Review warnings tab for specific issues
- Try simpler test scripts first
Solution:
- Implement missing Dreamcast types (
game_object_t,vec3_t, etc.) - Review TODOs tab for manual implementation tasks
- Check type mappings are correct
- Verify header includes are available
For detailed guides and workflows, see the Pages documentation:
- Guia de Port para SEGA Dreamcast - Complete porting guide
- Como Usar o Transpiler - Usage tutorial
- IL2CPP Integration - IL2CPP mode details
- Workflow Otimizado - Hybrid workflow
- โ Start with simple scripts to test the workflow
- โ Review all warnings and TODOs before using generated code
- โ Use IL2CPP mode for reference, Advanced Parser for production
- โ Implement Dreamcast runtime incrementally
- โ Test frequently on Dreamcast hardware
- โ Keep C# code Dreamcast-friendly (avoid heavy allocations)
- โ Document your manual fixes for future reference
- โ Don't blindly use generated code without review
- โ Don't use IL2CPP runtime on Dreamcast (memory limit)
- โ Don't expect 100% automatic conversion
- โ Don't ignore warnings and TODOs
- โ Don't use reflection or heavy C# features
- โ Don't allocate large amounts of memory per frame
- โ Don't forget to implement Unity runtime equivalents
License to use only for NON-COMMERCIAL PROJECTS.
Happy Dreamcast Development! ๐ฎโจ