Home

Awesome

SaintsDraw

openupm openupm

SaintsDraw allow you to draw arrow, circle, and arc in Unity, using Gizmos or LineRenderer

Developed by: TylerTemp, 墨瞳

Unity: 2019.1 or above

Installation

Change Log

1.0.2

Add camera & distance for DrawWireRectTransform to support camera mode of a canvas.

See the full change log.

Draw

Arrow

arrow

Using Arrow.Draw to draw an arrow, which has parameters:

Append a LineRenderer as the first parameter to draw the arrow using LineRenderer

using SaintsDraw;
Arrow.Draw(Vector3.zero, Vector3.one);

Circle (Disk)

circle

Using Circle.Draw to draw an circle (disk), which has parameters:

Using Circle.DrawBySegCount to draw an circle with fixed segment steps, which means each segment will have the same angle. It has the same parameters as Circle.Draw except int numSegments is replaced by float segAngle.

Append a LineRenderer as the first parameter to draw the arc using LineRenderer

using SaintsDraw;
Circle.Draw(Vector3.zero, 5f, Vector3.up, 40);

Arc

circle_arc

Using Arc.Draw to draw an arc, which has parameters:

Using Arc.DrawBySegCount to draw an with fixed segment steps, which means each segment will have the same angle. It has the same parameters as Arc.Draw except int numSegments is replaced by float segAngle.

Append a LineRenderer as the first parameter to draw the arc using LineRenderer

using SaintsDraw;
Arc.Draw(Vector3.zero, 5f, 60f, 120f, Vector3.up, Vector3.left, 40);

DrawWireRectTransform

UIGizmos.DrawWireRectTransform(RectTransform rectTransform, Camera camera=null, float distance=5f)

Draw a wireframe of a RectTransform in the scene view. This works even the RectTransform has rotation and scale.

Parameters:

UIGizmos.DrawWireRectTransform(GetComponent<RectTransform>());

DrawWireRectTransform

Some Tools

Gizmos Color

using (new ColorScoop(Color.green))
{
    Arrow.Draw(Vector2.zero, Vector2.up);
}

Gizmos Matrix

Useful if you want to draw gizmos in local space inheriting parent's scale and rotation

using (new MatrixScoop(transform.localToWorldMatrix))
{
    Arrow.Draw(Vector2.zero, Vector2.up);
}

Arc Tools

this will normalized your angle, which allow over 360 but will has no overlap

(float normFromArc, float normToArc) = Arc.NormalAngleRange(_fromArc, _toArc);

this will display an arrow from arc center to the angle you want to check, helpful when testing upward and plate

Vector3 startPos = Arc.GetDirection(_upward, _plate, angle).normalized * _arcRadis;
Arrow.Draw(Vector3.zero, startPos);