Unity Sentry-Gemini Debugger – Smash Unity Crashes with One-Click AI Fixes ๐Ÿ› ๏ธ๐Ÿค–

์ž‘์„ฑ์ž

์นดํ…Œ๊ณ ๋ฆฌ:

โ† ํ”ผ๋“œ๋กœ
DEV Community ยท Batuhan ยท 2026-08-06 ๊ฐœ๋ฐœ(SW)

Unity Sentry-Gemini Debugger: How We Automated Game Bug Smashes with Sentry and AI

This post is submitted for the DEV’s Summer Bug Smash Challenge (Smash Stories / Best Use of Sentry / Best Use of Google AI categories).

๐Ÿ› The Bug

While playtesting our latest Unity game, we hit a frustrating, intermittent crash. The game would freeze, and our console log was cluttered with a cryptic NullReferenceException. Because the crash occurred randomly during game state changes, finding the exact script reference and state corruption manually was like looking for a needle in a haystack.

๐Ÿ” The Discovery

Fortunately, we had Sentry integrated into our build. An alert fired on our Sentry dashboard, pinpointing the issue:

  • Error: NullReferenceException: Object reference not set to an instance of an object
  • Location: PlayerController.cs in Update() at line 42.

Sentry gave us the trace, but we still faced a developer’s daily friction: opening the codebase, finding the script, scrolling to line 42, analyzing the context, and writing the fix. This manual cycle felt too slow.

๐Ÿ•ต๏ธโ€โ™‚๏ธ The Investigation & The Tool We Built

We wanted to automate this friction away. So, we built a custom tool directly inside the game engine: Unity Sentry-Gemini Debuggerโ€”a lightweight Unity Editor extension.

We designed it with zero external DLL dependencies to prevent assembly conflicts in Unity. Using C# and regex:

  1. It queries the Sentry API to retrieve the latest project crashes and stack traces inside the Editor.
  2. It automatically matches the stacktrace to our local script (PlayerController.cs) and renders a live code preview of the crash site.
  3. It compiles the context (Sentry error + local code) and queries Google Gemini API for an immediate fix.

๐Ÿš€ The Resolution

We launched our new editor tool (Window > Sentry-Gemini Debugger), fetched the active Sentry issue, and clicked Analyze with Gemini.

Gemini instantly detected that we were attempting to access a UI component ref that hadn’t been initialized during Awake() when the game state reloaded. It provided the corrected code block.

We clicked Apply C# Fix. The tool:

  1. Created a .bak backup of PlayerController.cs.
  2. Overwrote the code with the fix.
  3. Triggered a native Unity compilation reimport.

The bug was smashed, the script recompiled, and playtests resumedโ€”all in under 15 seconds without leaving the Unity Editor!

๐Ÿ› ๏ธ Tech Stack & Open Source Code

๐Ÿ’ก What We Learned (Sentry & AI Impact)

By bridging real-time error tracking (Sentry) and generative AI (Gemini) directly inside the Unity Engine, we turned debugging from a detective chore into a one-click automation.

์›๋ฌธ์—์„œ ๊ณ„์† โ†—

์ถ”์ถœ ๋ณธ๋ฌธ ยท ์ถœ์ฒ˜: dev.to ยท https://dev.to/batuta/unity-sentry-gemini-debugger-smash-unity-crashes-with-one-click-ai-fixes-3geb

์ฝ”๋ฉ˜ํŠธ

๋‹ต๊ธ€ ๋‚จ๊ธฐ๊ธฐ

์ด๋ฉ”์ผ ์ฃผ์†Œ๋Š” ๊ณต๊ฐœ๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ํ•„์ˆ˜ ํ•„๋“œ๋Š” *๋กœ ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค