Unityunity_crashreporting_bugsplat_small

6 minute read

The BugSplatUnity package contains everything you need to integrate your Unity application with BugSplat. Before you proceed, please ensure you have met the following prerequisites:

Once you've downloaded BugSplatUnity.unitypackage, double-click the file to launch Unity. You will be prompted to create or select a project. Once you've selected a project, click "Import" to import BugSplat. After the import is complete, the tool will be ready to use.

(Note: At least for our team, Mac users have to manually import the package contents.)

Exploring the BugSplat Sample

To get a feel of the BugSplat service before using it in your application, try out the debug scene embedded as a sample in the BugSplat Report Tool.

Double-click the debug scene icon found in the Projects tab at Assets > bugsplat > report > scene > debug.

Unity, crash report, crash reporting

Hit the Play button and you will see our example running as shown below. The scene consists of three test buttons and an animated cube.

The Prompted Exception button will create an interactive crash report dialog that allows the user to provide information and confirm the crash report should be sent to BugSplat.

The Custom Exception button will create a report using a custom Exception (i.e., created using throw new Exception(“msg”).

The Null Reference Exception button will force a Null Reference Exception (i.e., a common runtime exception in Unity).

Unity, crash report, crash reporting

By default, crashes are posted to the BugSplat database "Fred". Login to BugSplat with the username Fred and password Flintstone and navigate to the All Crashes page to view these crash reports.

If you would like to post crashes to your own database, select the app GameObject and in the Inspector expand the Reporter field. Provide your own values for Database, App, Version and the optional Key parameters.

Unity, crash report, crash reporting

Integrating Into Your Game


Follow the steps below to create a Reporter instance that will handle the detection of Errors and also allow users to send their own reports to the BugSplat server.

  1. Create an empty script or modify an existing script.
  2. Add using BugSplat; to add the BugSplat namespace to your script.
  3. Add public Reporter reporter; to add a Reporter as a public property.
  4. On the Start or Awake method call reporter.Initialize(gameObject); to configure BugSplat to start watching for Exceptions.
  5. Unity, crash report, crash reporting
  6. Add your script to a GameObject and check that Reporter is shown in the Inspector. Unity, crash report, crash reporting
  7. Configure your BugSplat integration:
  8. FieldDescription
    DatabaseTarget database where reports will be sent
    AppApp name string
    VersionVersion string of the app
    QuietFlag that allows ReportComponent to emit debug logs so the user can confirm things are working
    Previous*Last sent report
    Generate ScreenshotsFlag that allows the capture of screenshots before a Report is generated
    Generate Log FileFlag that allows the creation of a text file with all logs before the Report
    PromptFlag that allows the use of a dialog before sending a Report
    IgnoredNumber of ignored repeated reports
    LogsList of detected Unity logs
    IgnoredNumber of ignored repeated reports
    CountNumber of Reports sent

Exporting


Mac OS X

  1. File > Build Settings...
  2. Click PC, Mac & Linux Standalone
  3. Optional: Click Development build to enable line numbers
  4. Unity, crash report, crash reporting
  5. Click Build and Run

Windows 7-10

  1. File > Build Settings...
  2. Add Open Scenes
  3. Click PC, Mac & Linux Standalone
  4. Optional: Click Copy PDB files to enable line numbers
  5. Unity, crash report, crash reporting
  6. Click Build and Run

Universal Windows Platform

  1. File > Build Settings...
  2. Add Open Scenes
  3. Use the following settings to get function names and line numbers
  4. Unity, crash report, crash reporting
  5. Click Build
  6. Select a folder for the Windows Store Visual Studio project to be saved in
  7. Open the newly created project in Visual Studio
  8. Add the Internet (Client) permission to the Package.appxmanifest file
  9. Unity, crash report, crash reporting Unity, crash report, crash reporting Unity, crash report, crash reporting
  10. Run your app with Visual Studio and click continue when it catches an exception