Skip to content

Instantly share code, notes, and snippets.

@AngryAnt
Created August 7, 2013 18:04
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AngryAnt/6176728 to your computer and use it in GitHub Desktop.
Save AngryAnt/6176728 to your computer and use it in GitHub Desktop.
Abusing reflection and the internal Unity player build error function to get stacktrace-less error logs. Not recommended for anything sane.
using UnityEngine;
using System.Reflection;
public class TerriblyHackyLog : MonoBehaviour
{
void Start ()
{
Log ("Aaaaarrrrgh!");
}
static void Log (string message)
{
typeof (Debug).GetMethod (
"LogPlayerBuildError",
BindingFlags.Static | BindingFlags.InvokeMethod | BindingFlags.NonPublic
).Invoke (
null,
new object[]{message, "", 0, 0}
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment