public void ShowTriangle(string id, Triangle triangle, DebugColor color)
        {
            if (string.IsNullOrEmpty(id))
            {
                Debug.LogWarning("id is null or empty");
                id = k_DefaultId;
            }

            var renderer = GetLineRenderer(color);

            if (renderer != null)
            {
                if (!m_Polygons.ContainsKey(id))
                {
                    m_Polygons.Add(id, new List <Renderer>());
                }

                m_Polygons[id].Add(renderer);

                var points = new Vector3[3];
                points[0] = new Vector3(triangle.PointA.Position.x, triangle.PointA.Position.y);
                points[1] = new Vector3(triangle.PointB.Position.x, triangle.PointB.Position.y);
                points[2] = new Vector3(triangle.PointC.Position.x, triangle.PointC.Position.y);

                ShowLines(renderer, points, true);
            }
        }
Example #2
0
        public static string GetColorStr(DebugColor color)
        {
            string colStr = "<color=#000000>";

            switch (color)
            {
            default:
            case DebugColor.Black:
                colStr = "<color=#000000>";
                break;

            case DebugColor.Blue:
                colStr = "<color=#0000ff>";
                break;

            case DebugColor.Green:
                colStr = "<color=#00ff00>";
                break;

            case DebugColor.Grey:
                colStr = "<color=#888888>";
                break;

            case DebugColor.Red:
                colStr = "<color=#ff000>";
                break;
            }

            return(colStr);
        }
        public void ShowCircle(string id, Circle circle, DebugColor color)
        {
            if (string.IsNullOrEmpty(id))
            {
                Debug.LogWarning("id is null or empty");
                id = k_DefaultId;
            }

            var renderer = GetLineRenderer(color);

            if (renderer != null)
            {
                if (!m_Circles.ContainsKey(id))
                {
                    m_Circles.Add(id, new List <Renderer>());
                }

                m_Circles[id].Add(renderer);

                var points = new List <Vector3>();

                for (var i = 0; i < k_CircleCount; i++)
                {
                    points.Add(new Vector3(circle.Radius * Mathf.Cos(i * 2f * Mathf.PI / k_CircleCount) + circle.Centre.Position.x,
                                           circle.Radius * Mathf.Sin(i * 2f * Mathf.PI / k_CircleCount) + circle.Centre.Position.y));
                }

                ShowLines(renderer, points.ToArray(), true);
            }
        }
 public static void Print(string text, DebugColor color = DebugColor.None, string prefix = "", DebugColor colorPrefix = DebugColor.None, bool clear = false, Type type = null)
 {
     if (!Application.CanDebug(type))
     {
         return;
     }
     if (clear)
     {
         Clear();
     }
     if (prefix.IsNullOrEmpty())
     {
         if (color == DebugColor.None)
         {
             Print(text, clear, type);
         }
         else
         {
             Debug.Log($"<color={color}>{text}</color>");
         }
     }
     else
     {
         var finalPrefix = colorPrefix == DebugColor.None ? prefix : $"<color={colorPrefix}>{prefix}</color>";
         var finalText   = color == DebugColor.None  ? text : $"<color={color}>{text}</color>";
         Debug.Log($"[{finalPrefix}] > {finalText}");
     }
 }
        public void DrawFatSegment(Vect a, Vect b, double radius, DebugColor outlineColor, DebugColor fillColor)
        {
            var pos1 = new Vector2((float)a.X, (float)a.Y);
            var pos2 = new Vector2((float)b.X, (float)b.Y);

            primitiveBatch.DrawLine(pos1, pos2, new Color(fillColor.Red, fillColor.Green, fillColor.Blue));
        }
        public void ShowLineSegment(string id, LineSegment lineSegment, DebugColor color)
        {
            if (string.IsNullOrEmpty(id))
            {
                Debug.LogWarning("id is null or empty");
                id = k_DefaultId;
            }

            var renderer = GetLineRenderer(color);

            if (renderer != null)
            {
                if (!m_LineSegments.ContainsKey(id))
                {
                    m_LineSegments.Add(id, new List <Renderer>());
                }

                m_LineSegments[id].Add(renderer);

                var points = new Vector3[2];
                points[0] = new Vector3(lineSegment.PointA.Position.x, lineSegment.PointA.Position.y);
                points[1] = new Vector3(lineSegment.PointB.Position.x, lineSegment.PointB.Position.y);

                ShowLines(renderer, points, false);
            }
        }
        public void DrawPolygon(Vect[] vectors, double radius, DebugColor outlineColor, DebugColor fillColor)
        {
            Vector2[] vertices = vectors.Select(v => new Vector2((float)v.X, (float)v.Y)).ToArray();

            primitiveBatch.DrawPolygon(vertices, new Color(fillColor.Red, fillColor.Green, fillColor.Blue),
                                       new Color(outlineColor.Red, outlineColor.Green, outlineColor.Blue));
        }
        public void DrawSegment(Vect a, Vect b, DebugColor color)
        {
            var pos1 = new Vector2((float)a.X, (float)a.Y);
            var pos2 = new Vector2((float)b.X, (float)b.Y);

            primitiveBatch.DrawLine(pos1, pos2, new Color(color.Red, color.Green, color.Blue));
        }
 public void DrawSegment(Vect a, Vect b, DebugColor color)
 {
     stringBuilder.Append($"DrawFatSegment\n");
     stringBuilder.Append($"a = {a}\n");
     stringBuilder.Append($"b = {b}\n");
     stringBuilder.Append($"color = {color}\n");
 }
 public void DrawDot(double size, Vect pos, DebugColor color)
 {
     stringBuilder.Append($"DrawDot\n");
     stringBuilder.Append($"size = {size}\n");
     stringBuilder.Append($"pos = {pos.X}, {pos.Y}\n");
     stringBuilder.Append($"color = {color}\n");
 }
Example #11
0
 public void Log(TLabel label, FastString msg, DebugColor colorType = DebugColor.White)
 {
     if (m_SwitchFlag)
     {
         Debug.Log($"<color=#{s_ColorStringArray[(int)colorType]}>[L] - [{label}] {msg}</color>");
     }
 }
Example #12
0
        public virtual void Draw(GameTime gameTime, IDebugDraw debugDraw)
        {
            space.DebugDraw(debugDraw);

            var colorMagenta = new DebugColor(1, 0, 1, 1);

            debugDraw.DrawCircle(ChipmunkDemoGame.ChipmunkDemoMouse, 0.0, 5, colorMagenta, colorMagenta);
        }
Example #13
0
 public static void LogMessage(object message, DebugColor color = DebugColor.black)
 {
     if (!isShowLog)
     {
         return;
     }
     UnityEngine.Debug.Log($"<color={color.ToString()}><size=12><color=black>CUSTOM_DEBUG >>></color></size> Message - {message}.</color>");
 }
        public void DrawCircle(Vect pos, double angle, double radius, DebugColor outlineColor, DebugColor fillColor)
        {
            var center = new Vector2((float)pos.X, (float)pos.Y);

            primitiveBatch.DrawCircle(center, (float)radius,
                                      new Color(fillColor.Red, fillColor.Green, fillColor.Blue),
                                      new Color(outlineColor.Red, outlineColor.Green, outlineColor.Blue)
                                      );
        }
 public void DrawFatSegment(Vect a, Vect b, double radius, DebugColor outlineColor, DebugColor fillColor)
 {
     stringBuilder.Append($"DrawFatSegment\n");
     stringBuilder.Append($"a = {a}\n");
     stringBuilder.Append($"b = {b}\n");
     stringBuilder.Append($"radius = {radius}\n");
     stringBuilder.Append($"outlineColor = {outlineColor}\n");
     stringBuilder.Append($"fillColor = {fillColor}\n");
 }
 public void DrawCircle(Vect pos, double angle, double radius, DebugColor outlineColor, DebugColor fillColor)
 {
     stringBuilder.Append($"DrawCircle\n");
     stringBuilder.Append($"pos = {pos.X}, {pos.Y}\n");
     stringBuilder.Append($"angle = {angle}\n");
     stringBuilder.Append($"radius = {radius}\n");
     stringBuilder.Append($"outlineColor = {outlineColor}\n");
     stringBuilder.Append($"outlineColor = {fillColor}\n");
 }
        private Color GetColor(DebugColor color)
        {
            switch (color)
            {
            case DebugColor.Black:
                return(new Color(0, 0, 0, 1));

            case DebugColor.Gray:
                return(new Color(0.5f, 0.5f, 0.5f, 1));

            case DebugColor.Silver:
                return(new Color(0.75f, 0.75f, 0.75f, 1));

            case DebugColor.White:
                return(new Color(1, 1, 1, 1));

            case DebugColor.Red:
                return(new Color(1, 0, 0, 1));

            case DebugColor.Lime:
                return(new Color(0, 1, 0, 1));

            case DebugColor.Blue:
                return(new Color(0, 0, 1, 1));

            case DebugColor.Maroon:
                return(new Color(0.5f, 0, 0, 1));

            case DebugColor.Green:
                return(new Color(0, 0.5f, 0, 1));

            case DebugColor.Navy:
                return(new Color(0, 0, 0.5f, 1));

            case DebugColor.Aqua:
                return(new Color(0, 1, 1, 1));

            case DebugColor.Fuchsia:
                return(new Color(1, 0, 1, 1));

            case DebugColor.Yellow:
                return(new Color(1, 1, 0, 1));

            case DebugColor.Teal:
                return(new Color(0, 0.5f, 0.5f, 1));

            case DebugColor.Purple:
                return(new Color(0.5f, 0, 0.5f, 1));

            case DebugColor.Olive:
                return(new Color(0.5f, 0.5f, 0, 1));

            default:
                return(Color.clear);
            }
        }
Example #18
0
        /// <summary>
        /// Writes debug text to the screen.
        /// </summary>
        /// <param name="x">The X position, in cells.</param>
        /// <param name="y">The Y position, in cells.</param>
        /// <param name="foreColor">The foreground color of the text.</param>
        /// <param name="backColor">The background color of the text.</param>
        /// <param name="message">The message to write.</param>
        public static void DebugTextWrite(int x, int y, DebugColor foreColor, DebugColor backColor, IntPtr message)
        {
            var attr   = (byte)(((byte)backColor << 4) | (byte)foreColor);
            var format = stackalloc byte[3];

            format[0] = (byte)'%';
            format[1] = (byte)'s';
            format[2] = 0;
            NativeMethods.bgfx_dbg_text_printf((ushort)x, (ushort)y, attr, format, message);
        }
Example #19
0
    public void Init()
    {
        DebugColor.Blue("Init buttons acc");
        killBtn.onClick.AddListener(() => {
            CharacterManager.Instance.JudgeCurrentCharacter(false);
        });

        freeBtn.onClick.AddListener(() => {
            CharacterManager.Instance.JudgeCurrentCharacter(true);
        });
    }
        public void DrawPolygon(Vect[] vectors, double radius, DebugColor outlineColor, DebugColor fillColor)
        {
            stringBuilder.Append($"DrawPolygon\n");

            for (int i = 0; i < vectors.Length; i++)
            {
                stringBuilder.Append($"vectors[{i}] = {vectors[i]}\n");
            }
            stringBuilder.Append($"radius = {radius}\n");
            stringBuilder.Append($"outlineColor = {outlineColor}\n");
            stringBuilder.Append($"fillColor = {fillColor}\n");
        }
        private LineRenderer GetLineRenderer(DebugColor color)
        {
            var renderer = GetFromPool(m_Settings.LinePrefab, m_LinePool) as LineRenderer;

            if (renderer != null)
            {
                var material = GetMaterial(color);
                renderer.material = material;
            }

            return(renderer);
        }
        private MeshRenderer GetMeshRenderer(DebugColor color)
        {
            var renderer = GetFromPool(m_Settings.DotPrefab, m_DotPool) as MeshRenderer;

            if (renderer != null)
            {
                var material = GetMaterial(color);
                renderer.material = material;
            }

            return(renderer);
        }
        private Material GetMaterial(DebugColor color)
        {
            if (!m_ColorMaterials.TryGetValue(color, out Material material))
            {
                material       = Material.Instantiate(m_Settings.SolidColorMaterial);
                material.color = GetColor(color);

                m_ColorMaterials[color] = material;
            }

            return(material);
        }
        private void DrawDebugRect()
        {
            if (!DebugDraw)
            {
                return;
            }
            var colorEdge = DebugColor.WithAlpha(0.50f).Convert();
            var colorFill = DebugColor.WithAlpha(0.25f).Convert();
            var aabb = Owner.GetComponent<BoundingBoxComponent>().AABB;

            const int ppm = EyeManager.PIXELSPERMETER;
            var rect = new Godot.Rect2(aabb.Left * ppm, aabb.Top * ppm, aabb.Width * ppm, aabb.Height * ppm);
            debugNode.DrawRect(rect, colorEdge, filled: false);
            rect.Position += new Godot.Vector2(1, 1);
            rect.Size -= new Godot.Vector2(2, 2);
            debugNode.DrawRect(rect, colorFill, filled: true);
        }
Example #25
0
    public void GenerateNewCharges(int count = 3)
    {
        for (int i = 0; i < textsContainer.childCount; i++)
        {
            // Generate the charges
            ChargeData charge;
            bool       isDuplicate    = false;
            int        iterationCount = 0;

            // If the charge is duplicate, generate a new one
            do
            {
                charge      = Helpers.GetRandomObjectFromList <ChargeData>(chargeDatas);
                isDuplicate = curCharges.Contains(charge);

                // Exit condition to prevent infinite looping
                iterationCount++;
                if (iterationCount > 1000)
                {
                    DebugColor.Red("1000 iterations reached in loop, there must be a problem");
                    return;
                }
            } while (isDuplicate);


            // Add the charges
            curCharges.Add(charge);

            // Display the generated charge
            var child       = textsContainer.GetChild(i);
            var tmComponent = child.GetComponent <TextMeshProUGUI>();

            // Check if the child has a TextMeshProUGUI component
            if (tmComponent != null)
            {
                tmComponent.text = charge.description;
            }
            else
            {
                DebugColor.Red("No TextMeshProUGUI Component found on " + child.name);
            }
        }
    }
            static Brush ToBrush(DebugColor color)
            {
                switch (color)
                {
                case DebugColor.Black:
                    return(Brushes.Black);

                case DebugColor.Red:
                    return(Brushes.Tomato);

                case DebugColor.Green:
                    return(Brushes.DarkOliveGreen);

                case DebugColor.Blue:
                    return(Brushes.AliceBlue);

                case DebugColor.Yellow:
                    return(Brushes.LightGoldenrodYellow);

                default:
                    return(Brushes.Black);
                }
            }
        public void ShowPoint(string id, Point point, DebugColor color)
        {
            if (string.IsNullOrEmpty(id))
            {
                Debug.LogWarning("id is null or empty");
                id = k_DefaultId;
            }

            var renderer = GetMeshRenderer(color);

            if (renderer != null)
            {
                if (!m_Points.ContainsKey(id))
                {
                    m_Points.Add(id, new List <Renderer>());
                }

                m_Points[id].Add(renderer);

                renderer.transform.position = point.Position;
                renderer.gameObject.SetActive(true);
            }
        }
Example #28
0
        public static void Log(object str, DebugColor color, params object[] args)
        {
//            DebugInConsole(str, color, args);

            //LogInUnity(str, color, args);
        }
Example #29
0
 public static void WarningInUnity(object str, DebugColor color, params object[] args)
 {
     UnityEngine.Debug.LogWarningFormat("{0}{1}</color>", GetColorStr(color),
                                        string.Format(str.ToString(), args));
 }
Example #30
0
 /// <summary>
 /// Writes debug text to the screen.
 /// </summary>
 /// <param name="x">The X position, in cells.</param>
 /// <param name="y">The Y position, in cells.</param>
 /// <param name="color">The color of the text.</param>
 /// <param name="message">The message to write.</param>
 public static void DebugTextWrite(int x, int y, DebugColor foreColor, DebugColor backColor, IntPtr message)
 {
     var attr = (byte)(((byte)backColor << 4) | (byte)foreColor);
     var format = stackalloc byte[3];
     format[0] = (byte)'%';
     format[1] = (byte)'s';
     format[2] = 0;
     NativeMethods.bgfx_dbg_text_printf((ushort)x, (ushort)y, attr, format, message);
 }
Example #31
0
 public static void DebugInConsole(object str, DebugColor color, params object[] args)
 {
     Console.WriteLine(str.ToString(), args);
 }
Example #32
0
 /// <summary>
 /// Writes debug text to the screen.
 /// </summary>
 /// <param name="x">The X position, in cells.</param>
 /// <param name="y">The Y position, in cells.</param>
 /// <param name="color">The color of the text.</param>
 /// <param name="format">The format of the message.</param>
 /// <param name="args">The arguments with which to format the message.</param>
 public static void DebugTextWrite(int x, int y, DebugColor foreColor, DebugColor backColor, string format, params object[] args)
 {
     DebugTextWrite(x, y, foreColor, backColor, string.Format(CultureInfo.CurrentCulture, format, args));
 }
Example #33
0
 /// <summary>
 /// Clears the debug text buffer.
 /// </summary>
 /// <param name="color">The color with which to clear the background.</param>
 /// <param name="smallText"><c>true</c> to use a small font for debug output; <c>false</c> to use normal sized text.</param>
 public static void DebugTextClear(DebugColor color = DebugColor.Transparent, bool smallText = false)
 {
     var attr = (byte)((byte)color << 4);
     NativeMethods.bgfx_dbg_text_clear(attr, smallText);
 }
Example #34
0
 /// <summary>
 /// Writes debug text to the screen.
 /// </summary>
 /// <param name="x">The X position, in cells.</param>
 /// <param name="y">The Y position, in cells.</param>
 /// <param name="color">The color of the text.</param>
 /// <param name="message">The message to write.</param>
 public static void DebugTextWrite(int x, int y, DebugColor foreColor, DebugColor backColor, string message)
 {
     var attr = (byte)(((byte)backColor << 4) | (byte)foreColor);
     NativeMethods.bgfx_dbg_text_printf((ushort)x, (ushort)y, attr, "%s", message);
 }