So, I'm migrating projects from SlimDX and .NET 3.5, and there are two things that were insanely helpful on that side that I can't seem to find via a search of Answers, the Forum, or the Unity script documentation.
In Visual Studio projects, I can set a "Check for arithmetic overflow/underflow" option under Settings, Build, Advanced Build Settings. Is there a way to do something similar in Unity? If there are overflow errors I want to know about it, not have it just wrap around into the negatives.
In .NET 3.5, I had it set up so that the following code would log absolutely anything that went wrong in my game:
[STAThread] static void Main() { Application.ThreadException += new System.Threading.ThreadExceptionEventHandler( Application_ThreadException ); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler( CurrentDomain_UnhandledException ); Application.Run( new Game() ); } private static void CurrentDomain_UnhandledException( object sender, UnhandledExceptionEventArgs e ) { File.AppendAllText( Configuration.GetLocalApplicationDataFolder() + "UnhandledErrors.txt", DateTime.Now + " (" + Game.GameVersionString + ")" + Environment.NewLine + "-----------------------------------" + "CurrentDomain_UnhandledException" + "-----------------------------------" + e.ExceptionObject.ToString() + Environment.NewLine ); AlertAndClose( (Exception)e.ExceptionObject ); } private static void Application_ThreadException( object sender, System.Threading.ThreadExceptionEventArgs e ) { File.AppendAllText( Configuration.GetLocalApplicationDataFolder() + "UnhandledErrors.txt", DateTime.Now + " (" + Game.GameVersionString + ")" + Environment.NewLine + "-----------------------------------" + "Application_ThreadException" + "-----------------------------------" + e.Exception.ToString() + Environment.NewLine ); AlertAndClose( e.Exception ); }
Obviously there are a few custom calls in there, but those are just illustrative; the main thing is what happens in Main. Basically, that lets me get exceptions off the main thread, and off any other threads, and have them be logged in a super useful format. I'm even packaging the debug symbols along with, so it gives me a line number along with any errors. For public betas, that is super useful in particular.
I know that Unity has the log under the _Data folder in windows (and something comparable on OSX), but that doesn't seem to log everything, it doesn't let me log custom messages to my knowledge, and it gets cleared out every time the player starts another game. I love that that Unity log exists, and it's not like I want to turn that off or anything, but I'd also love to be able to additionally do something more like the above in addition.
Any thoughts?