Unity integration guide

Add Bugsnag to your Unity games and applications.

After completing this guide, exceptions in your JavaScript, C#, and Boo Unity code as well as native crashes on iOS and Android devices are automatically detected and sent to Bugsnag.


  1. Download & Import the Bugsnag Unity Package

    Download the latest Bugsnag Unity Notifier. Double click the .unitypackage file, then click the import button to import Bugsnag into your Unity project.

    Import Package

Basic configuration

  1. Create a Bugsnag GameObject

    Create a new GameObject within your first/main scene (GameObject Menu -> Create Empty), and rename it to Bugsnag.

    Create GameObject

  2. Add the Bugsnag Component to Your GameObject

    With your new GameObject selected, add the Bugsnag component (Component Menu -> Scripts -> Bugsnag).

    Add Bugsnag Component

  3. Configure Your API Key

    Finally, configure your Bugsnag API Key in the component inspector. You can find your API key on the Project Settings page on your Bugsnag dashboard.

    Set API Key

Reporting unhandled errors

By default, Bugsnag will be notified about any exception logged to Debug.LogException. You can send additional log information to Bugsnag (eg. all Debug.LogError messages) by changing the Notify Level property in the Unity Inspector.

You can also change this setting in your scripts as follows:

Bugsnag.NotifyLevel = LogSeverity.Error;

Reporting handled errors

If you would like to send non-fatal or handled exceptions to Bugsnag, you can pass any Exception object to Bugsnag’s notify method in your Unity scripts:

Bugsnag.Notify(new System.InvalidOperationException("Non-fatal"));

Sending diagnostic data

It is often helpful to send us additional application-specific dianostic data, for example the name of a subsystem in which an exception occurred. If you would like to add custom data to your Bugsnag error reports, you can use the AddToTab method. Custom data is displayed inside tabs on each exception on your Bugsnag dashboard.

Bugsnag.AddToTab("system", "subsystem", "Player Mechanics");
Bugsnag.AddToTab("location", "region", "US");

Logging breadcrumbs

You can add custom log messages called “breadcrumbs” to document what user interactions occurred in your application prior to a crash. Each breadcrumb also records the time at which it was left. To record a breadcrumb:

Bugsnag.LeaveBreadcrumb("Player won");
Bugsnag.LeaveBreadcrumb("Button was clicked");

By default, we’ll store and send the last 20 breadcrumbs you leave before errors are sent to Bugsnag. If you’d like to increase this number, you can call SetBreadcrumbCapacity

Bugsnag.BreadcrumbCapacity = 50;

NOTE: Breadcrumbs are not supported for WebGL deployments.

Identifying users

Bugsnag helps you understand how many of your users are affected by each error. In order to do this, we send along a user ID with every exception. By default we will generate a unique ID and send this ID along with every exception from an individual device.

If you would like to override this userId, for example to set it to be a username of your currently logged in user, you can set the userId property:

Bugsnag.SetUser("userId", "User Name", "user@email.com");

You can also set the email and name of the user and these will be searchable in the dashboard.

Next steps

  • Explore a demo app
  • Get support for your questions and feature requests
  • View bugsnag-unity, the library powering this integration, on GitHub