During this process I have made a 3-leveled separation of concerns.

  1. A C# script that presents a hint to the player how bugs can be reported (the "Press F7 to report bug" message). BugReportFormLauncher
  2. A C# script (previously Boo) that implements the reporting form itself. BugReportForm
  3. A single point of entry, which is general and does the server communication bit. BugReportSender.Send(..)

Each level has a different set of requirements, and stays independent of the others.

Level 1

BugReportFormLauncher is the only super-simple kick-starter. Here's the requirements that I've taken into account:

  • Must be drag-drop-and-done
  • Must be C#
  • Must a quick read
  • Should be sufficient, even for collecting customized reports

It uses a single GUILayout.Label("F7 to report bug"); to present the hint, UnityEngine.SceneManagement.SceneManager.GetActiveScene().name to get the scene name, Input.GetKeyDown(KeyCode.F7) to launch the form, and two simple utility classes to fetch the standard log file and an automatically generated build-name for convenience.

The whole thing is 36 lines of C# code.

Level 2

BugReportForm is a bit more involved, because it needs to implement a comfortable contact point for the player:

  • Written in C#
  • Easily replacable
  • Excellent code quality
  • Handles disk / network errors gracefully

BugReportForm is a MonoBehaviour that automatically spawns a GameObject for itself and lives there as long as it's being used.

Launching it is just a simple matter of calling one static function.

It handles two different kinds of errors that need to be shown differently to the user, and it handles errors that can occur in connection with the server or on the file system. It uses Application.temporaryCachePath to store the screenshot, and cleans up after itself once the deed is done.

But at the end of the day, it's still very readable code, and can serve as an inspiration in different ways if you ever need to replace it with something else.

Level 3

BugReportSender.Send(..) is for the hard-core programmer who has a need to do everything himself / herself.

It is a straight forward static function that takes in all the raw data that is required for a bug report.

It doesn't handle any of the tasks that involves acquisition of the data, but it handles everything else. At this point, you're not likely going to replace it, so I figured Boo is the best choice of language here.

As a note to the intrigued reader: this function is as beautiful as the others. When I choose Boo, it's always for the excellent readability. When I choose C#... it's because I want to be more popular across the IDE divide.

I hope you like it!