示例#1
0
        /// <summary>
        /// Draws a line.
        /// </summary>
        /// <param name="start">The start point.</param>
        /// <param name="end">The end point.</param>
        /// <param name="color">The color of the line.</param>
        /// <param name="layer">The layer of the line.</param>
        /// <param name="thickness">The thickness of the line.</param>
        /// <param name="uiBatch">Whether to draw the line in the UI layer or not.</param>
        public static void DebugDrawLine(Vector2 start, Vector2 end, Color color, float layer, int thickness, bool uiBatch)
        {
            if (DebugEnabled == false)
            {
                return;
            }

            Texture2D box = AssetManager.Instance.LoadRawTexture2D($"{ContentGlobals.UIRoot}/Box.png");

            //Get rotation with the angle between the start and end vectors
            float lineRotation = (float)UtilityGlobals.TangentAngle(start, end);

            //Get the scale; use the X as the length and the Y as the width
            Vector2 diff      = end - start;
            Vector2 lineScale = new Vector2(diff.Length(), thickness);

            if (uiBatch == false)
            {
                SpriteRenderer.Instance.Draw(box, start, null, color, lineRotation, new Vector2(0f, 0f), lineScale, false, false, layer);
            }
            else
            {
                SpriteRenderer.Instance.DrawUI(box, start, null, color, lineRotation, new Vector2(0f, 0f), lineScale, false, false, layer);
            }
        }