Procedure:
When enabling the Cloud Diagnostics service for the first time, it is often worthwhile to test that the project is properly connected and the reports are received as expected. Once the setup is complete, this can be easily achieved by simulating or causing errors and exceptions in the project.
Detailed Steps and Sample Script:
- First, ensure the project is connected to a valid Dashboard project (Services > General Settings).
- Next, ensure that the Cloud Diagnostics package is installed and enabled.
- On newer versions of the Editor, the package can be found in the Unity Package Manager, and enabled in Services > Cloud Diagnostics > Configure.
- Once the services are enabled, you should now receive any reports on the Unity Cloud Dashboard under Cloud Diagnostics > Crashes and Exception Reporting.
- While there are numerous ways to cause exceptions or errors that will trigger dashboard reporting, here are just a few examples:
- Causing an actual exception or error
- Using Debug.LogException/LogError
- Using Utils.ForceCrash (to force a crash)
- The following script is a simple example of using buttons (created with Unity UI) to cause different exceptions or crashes:
using System; using UnityEngine; using UnityEngine.Diagnostics; using UnityEngine.UI; public class TestUI : MonoBehaviour { public Button quitButton; public Button throwExceptionButton; public Button forceCrashButton; public Button ooRErrorButton; public Button forceCrashAccessViolationButton; public Button nullReferenceErrorButton; public GameObject leaveEmpty; private void Start() { quitButton.onClick.AddListener(QuitApp); throwExceptionButton.onClick.AddListener(ThrowException); forceCrashButton.onClick.AddListener(ForceCrash); ooRErrorButton.onClick.AddListener(OORError); forceCrashAccessViolationButton.onClick.AddListener(ForceCrashAccessViolation); nullReferenceErrorButton.onClick.AddListener(NullReferenceTest); } public void QuitApp() { Application.Quit(); } public void ThrowException() { Debug.LogException(new Exception("Test Exception")); } public void ForceCrash() { Utils.ForceCrash(ForcedCrashCategory.FatalError); } public void ForceCrashAccessViolation() { Utils.ForceCrash(ForcedCrashCategory.AccessViolation); } public void OORError() { int[] testArray = new int[1]; int goingToFail = testArray[2]; } public void NullReferenceTest() { string willFail = leaveEmpty.name; } }
Additional Information: