Last active
April 1, 2020 12:10
-
-
Save korchoon/4a0891ebe52f5cf2c607b99fd117937e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #line hidden | |
| [Conditional("UNITY_EDITOR")] | |
| void Assert(bool value) | |
| { | |
| if (value) return; | |
| var msg = CallerSrcLine(1); | |
| UnityEngine.Debug.LogError(msg); | |
| throw new Exception(msg); | |
| } | |
| #line default | |
| string CallerSrcLine(int skipFrames = 0) | |
| { | |
| var trace = new StackTrace(1 + skipFrames, true); | |
| var fr = trace.GetFrame(0); | |
| var line = fr.GetFileLineNumber() - 1; | |
| var fileName = fr.GetFileName(); | |
| if (!File.Exists(fileName)) | |
| return string.Empty; | |
| var lines = File.ReadAllLines(fileName); | |
| return lines[line].Trim(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment