|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +This is a Unity plugin for BetaHub bug reporting that enables in-game bug submissions with video recording, screenshot capture, and log collection. The plugin is distributed as a Unity Package Manager (UPM) package. |
| 8 | + |
| 9 | +## Architecture |
| 10 | + |
| 11 | +### Core Components |
| 12 | + |
| 13 | +- **GameRecorder** (`Runtime/Scripts/GameRecorder.cs`): Handles video recording using FFmpeg with optimized GPU-based capture |
| 14 | +- **BugReportUI** (`Runtime/Scripts/BugReportUI.cs`): Main UI component for bug report submission form |
| 15 | +- **Issue** (`Runtime/Scripts/Issue.cs`): Data model representing bug reports and their upload state |
| 16 | +- **VideoEncoder** (`Runtime/Scripts/VideoEncoder.cs`): FFmpeg wrapper for video encoding with segmented recording |
| 17 | +- **Process Wrappers**: Platform-specific process handling for FFmpeg |
| 18 | + - **IProcessWrapper** (`Runtime/Scripts/IProcessWrapper.cs`): Interface for process abstraction |
| 19 | + - **DotNetProcessWrapper** (`Runtime/Scripts/DotNetProcessWrapper.cs`): .NET/Mono implementation |
| 20 | + - **NativeProcessWrapper** (`Runtime/Scripts/NativeProcessWrapper.cs`): IL2CPP implementation using native library |
| 21 | + |
| 22 | +### Assembly Definitions |
| 23 | + |
| 24 | +- **Runtime**: `io.betahub.bugreporter.asmdef` - Main plugin runtime assembly |
| 25 | +- **Editor**: `io.betahub.bugreporter.editor.asmdef` - Editor-only features (FFmpeg downloader) |
| 26 | + |
| 27 | +### Platform Support |
| 28 | + |
| 29 | +The plugin supports Windows, macOS, and Linux with special handling for IL2CPP builds: |
| 30 | +- **Mono/.NET**: Uses standard .NET Process class |
| 31 | +- **IL2CPP**: Requires `ENABLE_BETAHUB_FFMPEG` scripting symbol and native process wrapper libraries in `Plugins/` directories |
| 32 | + |
| 33 | +### Native Libraries |
| 34 | + |
| 35 | +Platform-specific native libraries for IL2CPP FFmpeg support: |
| 36 | +- Windows: `Plugins/x86_64/betahub_process_wrapper.dll` |
| 37 | +- macOS: `Plugins/macOS/libbetahub_process_wrapper.dylib` |
| 38 | +- Linux: `Plugins/Linux/x86_64/libbetahub_process_wrapper.so` |
| 39 | + |
| 40 | +## Development |
| 41 | + |
| 42 | +### Unity Package Structure |
| 43 | + |
| 44 | +This project follows Unity Package Manager conventions: |
| 45 | +- `package.json`: Package metadata and dependencies |
| 46 | +- `Runtime/`: Runtime scripts and assets |
| 47 | +- `Editor/`: Editor-only scripts |
| 48 | +- `Samples~/`: Sample scenes and scripts |
| 49 | +- Assembly definition files (`.asmdef`) organize code into separate assemblies |
| 50 | + |
| 51 | +### Testing |
| 52 | + |
| 53 | +The plugin includes a working demo scene in `Samples~/ExampleScene/` with: |
| 54 | +- Sample scene setup |
| 55 | +- Example integration with `RotateCube.cs` script |
| 56 | +- Pre-configured demo project settings for immediate testing |
| 57 | + |
| 58 | +### FFmpeg Integration |
| 59 | + |
| 60 | +The plugin automatically downloads FFmpeg binaries through the editor script `FfmpegDownloader.cs`. Video recording is implemented with: |
| 61 | +- Segmented recording (10-second segments, 60-second rolling window) |
| 62 | +- GPU-optimized capture using RenderTextures |
| 63 | +- Cross-platform process wrapper abstraction |
| 64 | +- Error handling and retry logic for file operations |
| 65 | + |
| 66 | +## Configuration |
| 67 | + |
| 68 | +### Required Settings for IL2CPP |
| 69 | + |
| 70 | +When building with IL2CPP scripting backend: |
| 71 | +1. Define `ENABLE_BETAHUB_FFMPEG` in Player Settings > Scripting Define Symbols |
| 72 | +2. Ensure native process wrapper libraries are included in build |
| 73 | + |
| 74 | +### Demo Project |
| 75 | + |
| 76 | +The plugin comes pre-configured with demo project credentials (`DEMO_PROJECT_ID = "pr-5287510306"`) for immediate testing. Reports submitted to the demo project are only visible to the submitter via email links. |
| 77 | + |
| 78 | +## Development Notes |
| 79 | + |
| 80 | +- Do not generate meta files, let Unity do this |
| 81 | +- Use `ruby validate_prefab.rb <prefab_path>` to validate Unity prefabs for duplicate IDs and broken references |
0 commit comments