Legacy Documentation: Version 4.5.0

Script language:

  • JS
  • C#
  • Boo
Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

CrashReport

Namespace: UnityEngine

Description

Holds data for a single application crash event and provides access to all gathered crash reports.

If compiled with appropriate settings, Unity will try to gather useful information, like location and thread stack traces, when your application crashes. Upon the next application start, if the data gathering was successful, all crash information will be accessible using this API.

To enable crash report generation, in iOS player settings set "Script Call Optimization" option to "Fast but no Exceptions". After you build your Xcode project in Unity, open it and edit trampoline file: Classes/CrashReporter.h. Change ENABLE_CUSTOM_CRASH_REPORTER define from 0 to 1.

Note: this API currently is available only for iOS targets.

CrashReport API requires Unity Pro license for target platform.

See Also: CrashReport.reports.

// This example shows a list of crash reports (if available),
// and allows you to output crash data to console, or
// delete them.
public class Crashes: MonoBehaviour {
	void OnGUI() {
		var reports = CrashReport.reports;
		GUILayout.Label("Crash reports:");
		foreach (var r in reports) {
			GUILayout.BeginHorizontal();
			GUILayout.Label("Crash: " + r.time);
			if (GUILayout.Button("Log")) {
				Debug.Log(r.text);
			}
			if (GUILayout.Button("Remove")) {
				r.Remove();
			}
			GUILayout.EndHorizontal();
		}
	}
}

Static Variables

lastReportReturns last crash report, or null if no reports are available.
reportsReturns all currently available reports in a new array.

Variables

textCrash report data as formatted text.
timeTime, when the crash occured.

Functions

RemoveRemove report from available reports list.

Static Functions

RemoveAllRemove all reports from available reports list.