Unity
Our Unity SDK builds on top of the .NET SDK and extends it with Unity specific features. It gives developers helpful hints for where and why an error or performance issue might have occurred.
Features:
- Automatically captures C# errors on multiple platforms, including: Android, iOS, macOS, Linux, Windows, and WebGL
- Line numbers for C# exceptions in IL2CPP builds.
- Native support for automatic crash error tracking for
- Android by using the Android SDK to support Java, Kotlin, C and C++
- iOS by using the iOS SDK to support Objective-C, Swift, C and C++
- Windows and Linux by using the Native SDK to support C and C++ with minidumps
- macOS by using the macOS SDK to support Objective-C, Swift, C and C++
- Screenshot attachments for errors
- ViewHierarchy attachments for errors
- Offline Caching stores event data to disk in case the device is not online
- Release Health to keep track of crash free users and sessions
- Automatically adding breadcrumbs for
- Unity's
Debug.Log
andDebug.LogWarning
- Scene load, unload, active change
- Unity's
- Event debouncing to handle high amounts of log output i.e. during
Update
On this page, we get you up and running with Sentry's SDK.
Don't already have an account and Sentry project established? Head over to sentry.io, then return to this page.
Install the package via the Unity Package Manager using a Git URL to Sentry's SDK repository:
https://github.com/getsentry/unity.git#3.2.0
Installing the SDK will add an entry to Unity's top menu: Tools
> Sentry
. When you first open the menu, a wizard will guide you through the process of associating your game with a Sentry project and setup the initial configuration for you. The minimum configuration required is the DSN to your project.
{
"public-dsn": "https://examplePublicKey@o0.ingest.sentry.io/0"
}
Sentry can be further configured via the Sentry configuration window or programatically.
Sentry saves your configuration to Assets/Resources/Sentry/SentryOptions.asset
and reads from there both at build time and runtime.
This snippet includes an intentional error, so you can test that everything is working as soon as you set it up.
using UnityEngine;
public class TestMonoBehaviour : MonoBehaviour
{
private GameObject testObject = null;
void Start()
{
Debug.Log("Captured Log"); // Adds a Breadcrumb
Debug.LogWarning("Captured Warning"); // Adds a Breadcrumb
Debug.LogError("Captured Error"); // Get's captured as an Error by default
// This will throw an unhandled 'NullReferenceException'
testObject.GetComponent<Transform>(); // Get's captured as an Error
}
}
Additionally, the packages also includes a sample called "Unity of Bugs" that you can import into your project through the Package Manager. The samples contain a variety of common bugs, including native errors, so you don't have to write them yourself.
Learn more about manually capturing an error or message in our Usage documentation.
To view and resolve the recorded error, log into sentry.io and select your project. Clicking on the error's title will open a page where you can see detailed information and mark it as resolved.
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").