private void HandleException(string condition, string stackTrace, LogType type) { if (type == LogType.Exception) { JollyDebug.LogException("{0}: {1}\n{2}", type, condition, stackTrace); } }
public static void ExecuteIf(string flagExpression, System.Action callback) { JollyDebug self = JollyDebug.Instance; if (self.EvaluateFlagExpression(flagExpression)) { callback.Invoke(); } }
public static void LogException(string message, params object[] args) { string formattedMessage = string.Format(message, args); JollyDebug self = JollyDebug.Instance; self.ExceptionToDisplayOnScreen = formattedMessage; Debug.LogError(formattedMessage); Debug.Break(); }
public static void LogExceptionIf(string flagExpression, string message, params object[] args) { JollyDebug self = JollyDebug.Instance; if (self.EvaluateFlagExpression(flagExpression)) { JollyDebug.LogException(message, args); } }
public static void SetFlag(string flag, bool value) { JollyDebug self = JollyDebug.Instance; int index = self.IndexOfFlag(flag); if (index >= 0) { self.FlagValues[index] = value; } }
public static bool GetFlag(string flag) { JollyDebug self = JollyDebug.Instance; int index = self.IndexOfFlag(flag); if (index < 0) { return(false); } return(!self.FlagValues[index]); }
private void DisplayFlags(JollyDebug jollyDebug) { IEnumerator enumerator = jollyDebug.DisplayFlagsEnumerator(); while (enumerator.MoveNext()) { string name = (string)enumerator.Current; EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField (name); JollyDebug.SetFlag (name, EditorGUILayout.Toggle (JollyDebug.GetFlag (name))); EditorGUILayout.EndHorizontal(); } }
public void Update() { if (!this.Enabled) { return; } JollyDebug.Assert(!this.OwnerIsMissing); foreach (Expression expression in this.Expressions) { expression.Update(); } }
private bool EvaluateFlagExpression(string flagExpression) { string[] substrings = flagExpression.Split(new char[] { ' ' }, System.StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < substrings.Length; ++i) { int index = this.IndexOfFlag(substrings[i]); JollyDebug.Assert(index > 0, "substring[{0}] == {1} not found in debug flags", i, substrings[i]); if (this.FlagValues[i]) { return(true); } } return(false); }
private void DisplayExpressions(JollyDebug jollyDebug) { IEnumerator enumerator = jollyDebug.ExpressionsByOwnerEnumerator; while (enumerator.MoveNext()) { JollyDebug.ExpressionsByOwner expressionsByOwner = (JollyDebug.ExpressionsByOwner)enumerator.Current; expressionsByOwner.Enabled = EditorGUILayout.InspectorTitlebar(expressionsByOwner.Enabled, expressionsByOwner.Owner); if (expressionsByOwner.Enabled) { foreach (JollyDebug.Expression expression in expressionsByOwner.Expressions) { EditorGUILayout.LabelField(expression.Name, expression.LastValue); } } } }
public static void Assert(bool expression, string message = "", params object[] args) { if (expression) { return; } string linewiseStackTrace = StackTraceUtility.ExtractStackTrace(); string firstLine = null; { string [] lines = linewiseStackTrace.Split(new char[] { '\n' }); { string [] skippedFirstLine = new string [lines.Length - 1]; System.Array.Copy(lines, 1, skippedFirstLine, 0, skippedFirstLine.Length); lines = skippedFirstLine; } firstLine = lines[0]; linewiseStackTrace = string.Join("\n", lines); } message = string.Format(message, args); JollyDebug.LogException("ASSERTION FAILED in {0}\n{1}\n{2}", firstLine, message, linewiseStackTrace); }
public static void Watch(MonoBehaviour owner, string name, bool boolValue) { JollyDebug self = JollyDebug.Instance; self.GetExpressionsForOwner(owner).GetExpression(name).SetLastValue(boolValue); }
public static void Watch(MonoBehaviour owner, string name, System.Func <bool> returnsBool) { JollyDebug self = JollyDebug.Instance; self.GetExpressionsForOwner(owner).Add(new Expression(name, returnsBool)); }