Skip to content

Instantly share code, notes, and snippets.

@pjc0247
Created June 15, 2016 09:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pjc0247/9fe1fb79ee938e4c22e0de35dfb0d415 to your computer and use it in GitHub Desktop.
Save pjc0247/9fe1fb79ee938e4c22e0de35dfb0d415 to your computer and use it in GitHub Desktop.
public void AddExceptionHandler()
{
// 유니티 메인 스레드가 아닌 다른 스레드에서 발생한 익셉션은 여기로 핸들링됩니다.
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
#pragma warning disable 0618
// 유니티 스레드에서 발생된 익셉션은 여기로 핸들링됩니다.
UnityEngine.Application.RegisterLogCallback((condition, stackTrace, type) =>
{
if (type != LogType.Exception)
return;
SendLog(condition, stackTrace);
});
#pragma warning restore 0618
}
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
if (e.ExceptionObject is Exception == false)
return;
var ex = e.ExceptionObject as Exception;
SendLog(ex.Message, ex.StackTrace);
}
private void SendLog(string msg, string stackTrace)
{
// 익셉션 로그를 저장하거나 / 서버로 전송한다
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment