Scripting API
Scripting API
Gizmos
Class in Abyss.Core, from Abyss.Core.
What a system draws lines with for the editor's Scene panel: the lines, loops, cubes, circles and spheres of Bevy's Gizmos, under the same names, for a game's C#.
public sealed class GizmosRemarks
A system's own. Each system is given one as SystemContext.Gizmos, as it is given its own CommandBuffer, so systems running at once draw without a lock. What a system draws is kept until it runs again, and the editor draws what every system drew when it last ran: while the game is paused, what it drew before the pause stays on the screen.
Kept only in the editor. The schedules the editor runs keep what is drawn (Schedule.DrawsGizmos); in a game on its own every call returns at once. A system that does nothing but draw belongs in a plugin marked EditorOnlyAttribute, which a game on its own never builds, and which the editor runs whether the game is edited, played or paused.
As Bevy's. Each call names its color, a circle is Gizmos.DefaultResolution lines unless it is told otherwise, a sphere is a circle round each of its own axes, and a cube is the edges of one a unit across, through the transform given (bevy_gizmos 0.19.1, MIT OR Apache-2.0, src/gizmos.rs:408-414, :429-441, :456-461, :502-515, :530-550 and :637-660; src/circles.rs:11-19, :128-141, :207-220 and :342-354). Colors are sRGB here, red, green, blue and alpha, as the editor's interface draws in, and every line is Gizmos.LineWidth pixels wide, the width Bevy's default group draws at (src/config.rs:270), so a game's C# and its Rust draw alike.
Properties
Enabled
public bool Enabled { get; internal set; }Whether what is drawn is kept, for the editor to draw: the schedule's Schedule.DrawsGizmos. Not, and every call returns at once.
Methods
Line
public void Line(Vector3 start, Vector3 end, Vector4 color)Draws a line from start to end.
Parameters
startendcolor
LineGradient
public void LineGradient(Vector3 start, Vector3 end, Vector4 startColor, Vector4 endColor)Draws a line from start to end, its color going from startColor to endColor along it.
Parameters
startendstartColorendColor
Ray
public void Ray(Vector3 start, Vector3 vector, Vector4 color)Draws a line from start as far and as long as vector.
Parameters
startvectorcolor
Linestrip
public void Linestrip(ReadOnlySpan<Vector3> positions, Vector4 color)Draws a line from each of positions to the next.
Parameters
positionscolor
Lineloop
public void Lineloop(ReadOnlySpan<Vector3> positions, Vector4 color)Draws a line from each of positions to the next, and from the last back to the first when there are more than two.
Parameters
positionscolor
Cube
public void Cube(Matrix4x4 transform, Vector4 color)Draws the twelve edges of a cube a unit across with its middle where it is, through transform: moved, turned and scaled by it.
Parameters
transformcolor
Circle
public void Circle(Vector3 position, Quaternion rotation, float radius, Vector4 color, int resolution = 32)Draws a circle of radius round position, across the X and Y axes as rotation turns them, with resolution lines.
Parameters
positionrotationradiuscolorresolution
Exceptions
ArgumentOutOfRangeException:resolutionis less than three, which is not a circle.
Sphere
public void Sphere(Vector3 position, Quaternion rotation, float radius, Vector4 color, int resolution = 32)Draws a sphere of radius round position as three circles, one round each of its axes as rotation turns them.
Parameters
positionrotationradiuscolorresolution
Exceptions
ArgumentOutOfRangeException:resolutionis less than three.
Constants
DefaultResolution
public const int DefaultResolution = 32How many lines a circle is drawn with unless it is told otherwise: Bevy's.
LineWidth
public const float LineWidth = 2How wide every line is drawn, in pixels: as wide as Bevy's default group draws.
