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.

Additional Features:

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.

Sentry captures data by using an SDK within your application’s runtime.

Install the package via the Unity Package Manager using a Git URL to Sentry's SDK repository:

Copied
https://github.com/getsentry/unity.git#2.3.0

Confirm the URL doesn't have a trailing whitespace at the end. The Unity Package Manager will fail to find the package if a trailing whitespace is appended.

The minimum configuration required is the DSN to your project.

Copied
___PUBLIC_DSN___

Sentry can be configured via the Sentry configuration window or programatically. The window can be accessed by going to Unity's top menu: Tools > Sentry.

Sentry window

Sentry saves your configuration to Assets/Resources/Sentry/SentryOptions.asset and reads from there at runtime.

This snippet includes an intentional error, so you can test that everything is working as soon as you set it up.

Copied
using UnityEngine;

public class TestMonoBehaviour : MonoBehaviour
{
    private GameObject testObject = null;

    void Start()
    {
        Debug.Log("Captured Log");              // Breadcrumb
        Debug.LogWarning("Captured Warning");   // Breadcrumb
        Debug.LogError("Captured Error");       // Captured Error

        // This will throw an unhandled Null Reference Exception
        testObject.GetComponent<Transform>();   // Captured error
    }
}

Additionally, the packages includes a sample called "Unity of bugs" that can optionally be imported 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.

Import Samples

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.

Help improve this content
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").