Exemplo n.º 1
0
 private void HandleException(string condition, string stackTrace, LogType type)
 {
     if (type == LogType.Exception)
     {
         JollyDebug.LogException("{0}: {1}\n{2}", type, condition, stackTrace);
     }
 }
Exemplo n.º 2
0
        public static void ExecuteIf(string flagExpression, System.Action callback)
        {
            JollyDebug self = JollyDebug.Instance;

            if (self.EvaluateFlagExpression(flagExpression))
            {
                callback.Invoke();
            }
        }
Exemplo n.º 3
0
        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();
        }
Exemplo n.º 4
0
        public static void LogExceptionIf(string flagExpression, string message, params object[] args)
        {
            JollyDebug self = JollyDebug.Instance;

            if (self.EvaluateFlagExpression(flagExpression))
            {
                JollyDebug.LogException(message, args);
            }
        }
Exemplo n.º 5
0
        public static void SetFlag(string flag, bool value)
        {
            JollyDebug self  = JollyDebug.Instance;
            int        index = self.IndexOfFlag(flag);

            if (index >= 0)
            {
                self.FlagValues[index] = value;
            }
        }
Exemplo n.º 6
0
        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();
     }
 }
Exemplo n.º 8
0
 public void Update()
 {
     if (!this.Enabled)
     {
         return;
     }
     JollyDebug.Assert(!this.OwnerIsMissing);
     foreach (Expression expression in this.Expressions)
     {
         expression.Update();
     }
 }
Exemplo n.º 9
0
 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);
             }
         }
     }
 }
Exemplo n.º 11
0
        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);
        }
Exemplo n.º 12
0
        public static void Watch(MonoBehaviour owner, string name, bool boolValue)
        {
            JollyDebug self = JollyDebug.Instance;

            self.GetExpressionsForOwner(owner).GetExpression(name).SetLastValue(boolValue);
        }
Exemplo n.º 13
0
        public static void Watch(MonoBehaviour owner, string name, System.Func <bool> returnsBool)
        {
            JollyDebug self = JollyDebug.Instance;

            self.GetExpressionsForOwner(owner).Add(new Expression(name, returnsBool));
        }