Advertisement
Guest User

Untitled

a guest
Feb 24th, 2018
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.60 KB | None | 0 0
  1. void OnEnable() {
  2.     Application.logMessageReceived += OnLogException;
  3. }
  4.  
  5. void OnDisable() {
  6.     Application.logMessageReceived -= OnLogException;
  7. }
  8.  
  9. static private void OnLogException(string _message, string _stackTrace, LogType _logType) {
  10.     if (_logType == LogType.Exception) {
  11.         if (Application.isEditor) {
  12.             // Only break in editor to allow examination of the current scene state.
  13.             Debug.Break();
  14.         } else {
  15.             // There's no standard way to return an error code to the OS,
  16.             // so just quit regularly.
  17.             File.WriteAllText("traceback.txt", _stackTrace);
  18.             Application.Quit();
  19.         }        
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement