Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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