### C# Immediate Mode Drawing Example Source: https://acegikmo.com/shapes/docs/index This script demonstrates how to draw 3D lines in immediate mode using the ImmediateModeShapeDrawer class. It configures line properties like geometry, thickness, and space, then draws lines along each axis. Attach this script to a GameObject to visualize the lines. ```csharp [ExecuteAlways] public class MyScript : ImmediateModeShapeDrawer { public override void DrawShapes( Camera cam ){ using( Draw.Command( cam ) ){ // set up static parameters. these are used for all following Draw.Line calls Draw.LineGeometry = LineGeometry.Volumetric3D; Draw.ThicknessSpace = ThicknessSpace.Pixels; Draw.Thickness = 4; // 4px wide // set static parameter to draw in the local space of this object Draw.Matrix = transform.localToWorldMatrix; // draw lines Draw.Line( Vector3.zero, Vector3.right, Color.red ); Draw.Line( Vector3.zero, Vector3.up, Color.green ); Draw.Line( Vector3.zero, Vector3.forward, Color.blue ); } } } ``` -------------------------------- ### Rectangle Configuration Source: https://acegikmo.com/shapes/docs/index Configure rectangles with options for size, corner radius, thickness, and dashing. ```APIDOC ## Rectangle ### Description Configure rectangles with options for size, corner radius, thickness, and dashing. Rectangles support rounded corners and can be hollow. ### Parameters #### Common Shape Properties - **Blend Mode** (string) - The blend mode to use when drawing this shape. - **Color** (Color) - The color of the rectangle. #### Rectangle Specific Properties - **Style** (string) - Shape style: 'Hard' or 'Rounded' corners, 'Hollow' or 'Solid'. - **Pivot** (string) - Pivot point for size: 'Bottom Left' or 'Center'. - **Width** (number) - The width of the rectangle. - **Height** (number) - The height of the rectangle. - **Thickness** (number) - The thickness of the rectangle's border. - **Thickness Space** (string) - The unit of measure for Thickness. - **Corner Radius Mode** (string) - 'Same' for all corners or 'Separate' for individual control. - **Corner Radius** (number) - The radius for all four corners (in meters). - **Corner Radii** (Array) - Individual corner radii (clockwise, starting bottom left, in meters). #### Dashing Properties - **Dashed** (boolean) - Whether the rectangle border is dashed or solid. - **Dash Space** (string) - Defines the space in which Size and Spacing are defined. Options: 'Meters', 'Relative' (to Thickness), 'Fixed Count'. - **Dash Snap** (string) - How dashes align to the shape's length. Options: 'Off', 'Tiling', 'End To End'. - **Dash Size** (number) - The length of a single dash. If 'Dash Space' is 'Fixed Count', this is the repeat count. - **Dash Spacing** (number) - The size of the space between dashes. If 'Dash Space' is 'Fixed Count', this is a fraction (0 to 1) representing space proportion. - **Dash Offset** (number) - Offset of dashes relative to the repeating period. - **Dash Type** (string) - Type of dash: 'Basic', 'Angled', or 'Rounded'. - **Dash Modifier** (string) - Modifies the shape of certain dash types. - **Fill** (Color) - Gradient color filling for the rectangle. ### Request Example ```json { "Width": 20, "Height": 10, "Corner Radius": 2, "Dashed": true, "Dash Space": "Meters", "Dash Size": 1, "Dash Spacing": 0.5, "Color": "#00FF00", "Style": "Rounded", "Fill": "#FFFF00" } ``` ### Response #### Success Response (200) - **Message** (string) - Confirmation of successful configuration. #### Response Example ```json { "Message": "Rectangle configured successfully." } ``` ``` -------------------------------- ### Dashed Rings & Arcs Configuration Source: https://acegikmo.com/shapes/docs/index Configure dashed rings and arcs with options for dash size, spacing, offset, and appearance. ```APIDOC ## Dashed Rings & Arcs ### Description Configure dashed rings and arcs with options for dash size, spacing, offset, and appearance. Dash Size and Dash Spacing can be defined in meters, relative to thickness, or as a fixed count across the shape. ### Parameters #### Common Shape Properties - **Blend Mode** (string) - The blend mode to use when drawing this shape. - **Color** (Color) - The color of the shape. - **Geometry** (string) - The geometry type: Flat 2D or Billboard. #### Ring & Arc Specific Properties - **Disc Type** (string) - Type of the shape: Disc, Pie, Ring, or Arc. - **Radius** (number) - The radius of the shape. - **Thickness** (number) - The thickness of the ring or arc. - **Angle Start** (number) - The start angle for Pie & Arc, stored as radians. - **Angle End** (number) - The end angle for Pie & Arc, stored as radians. - **Arc End Cap** (boolean) - Whether the arc ends should be rounded. #### Dashing Properties - **Dashed** (boolean) - Whether the shape is dashed or solid. - **Dash Space** (string) - Defines the space in which Size and Spacing are defined. Options: 'Meters', 'Relative' (to Thickness), 'Fixed Count'. - **Dash Snap** (string) - How dashes align to the shape's length. Options: 'Off', 'Tiling', 'End To End'. - **Dash Size** (number) - The length of a single dash. If 'Dash Space' is 'Fixed Count', this is the repeat count. - **Dash Spacing** (number) - The size of the space between dashes. If 'Dash Space' is 'Fixed Count', this is a fraction (0 to 1) representing space proportion. - **Dash Offset** (number) - Offset of dashes relative to the repeating period. - **Dash Type** (string) - Type of dash: 'Basic', 'Angled', or 'Rounded'. - **Dash Modifier** (string) - Modifies the shape of certain dash types. ### Request Example ```json { "Disc Type": "Ring", "Radius": 10, "Thickness": 2, "Dashed": true, "Dash Space": "Relative", "Dash Size": 1, "Dash Spacing": 1, "Dash Offset": 0.5, "Color": "#FF0000", "Blend Mode": "Alpha" } ``` ### Response #### Success Response (200) - **Message** (string) - Confirmation of successful configuration. #### Response Example ```json { "Message": "Dashed ring configured successfully." } ``` ``` -------------------------------- ### Draw Text with Shapes.Draw Text Mesh Pro Source: https://acegikmo.com/shapes/docs/index Render Text Mesh Pro text using the Shapes.Draw.Text method. This allows for text to be integrated into the immediate mode drawing system. Unspecified parameters will default to static properties. ```csharp Shapes.Draw.Text(position, textMeshProUGUIComponent, colorOverride); Shapes.Draw.Text(position, text); Shapes.Draw.Text(position, text, color); ``` -------------------------------- ### Draw Basic Shapes with Shapes.Draw Calls Source: https://acegikmo.com/shapes/docs/index Utilize various Shapes.Draw methods to render different geometric primitives. These include lines, polylines, discs, rings, pies, arcs, rectangles, polygons, triangles, quads, spheres, cuboids, cubes, cones, and tori. Draw calls follow a pattern: Draw.ShapeName(Positioning, Essentials, Specials, Coloring). ```csharp // Example: Draw a line Shapes.Draw.Line(startPoint, endPoint); // Example: Draw a filled disc Shapes.Draw.Disc(center, radius); // Example: Draw a rectangle border Shapes.Draw.RectangleBorder(bottomLeft, topRight); // Example: Draw a filled polygon Shapes.Draw.Polygon(vertices); // Example: Draw a sphere Shapes.Draw.Sphere(center, radius); ``` -------------------------------- ### Configure Drawing Styles with Shapes.Draw Static Properties Source: https://acegikmo.com/shapes/docs/index Set global styling properties for all subsequent shapes drawn using Shapes.Draw. This includes color, line geometry, thickness space, and line thickness. It's recommended to reset styles before drawing to ensure consistency. Unspecified parameters in draw calls will use these static properties. ```csharp Shapes.Draw.Color = Color.red; Shapes.Draw.LineGeometry = LineGeometry.Volumetric3D; Shapes.Draw.ThicknessSpace = ThicknessSpace.Pixels; Shapes.Draw.Thickness = 4; // Reset styles before drawing for consistency Shapes.Draw.ResetStyle(); ``` -------------------------------- ### Draw Temporary Polyline/Polygon Path (C#) Source: https://acegikmo.com/shapes/docs/index Creates and draws a temporary polyline or polygon. The mesh data is automatically disposed of at the end of the 'using' block. This method is flexible but recreates the mesh on each draw. ```csharp using( Draw.Command( cam ) ){ using( var p = new PolylinePath() ){ p.AddPoint( -1, -1 ); p.AddPoint( -1, 1 ); p.AddPoint( 1, 1 ); p.AddPoint( 1, -1 ); Draw.Polyline( p, closed:true, thickness:0.1f, Color.red ); // Drawing happens here } // Disposing of mesh data happens here } ``` -------------------------------- ### Draw Text using Persistent TextElement (C#) Source: https://acegikmo.com/shapes/docs/index Draws text efficiently using persistent TextElement objects. TextElements cache text data, reducing updates. Elements are initialized in Awake and must be disposed of in OnDestroy. ```csharp TextElement elemA, elemB; void Awake(){ elemA = new TextElement(); elemB = new TextElement(); } override void DrawShapes( Camera cam ){ using( Draw.Command( cam ) ){ Draw.Text( elemA, "Hello" ); // Draws text using the persistent element elemA Draw.Translate( 0, 1 ); Draw.Text( elemB, "This is performant text", Color.red ); } } void OnDestroy(){ elemA.Dispose(); // Important - you have to dispose text elements when you are done with them elemB.Dispose(); } ``` -------------------------------- ### Draw Textures with Shapes.Draw Texture Source: https://acegikmo.com/shapes/docs/index Render textures within a rectangular region using the Shapes.Draw.Texture method. This is useful for applying image-based elements in your scene via immediate mode drawing. Unspecified parameters will default to static properties. ```csharp Shapes.Draw.Texture(rectTransform, texture); Shapes.Draw.Texture(rectTransform, texture, color); ``` -------------------------------- ### Draw Persistent Polyline/Polygon Path (C#) Source: https://acegikmo.com/shapes/docs/index Draws a polyline or polygon using a persistent path object. The path is initialized in Awake and disposed of in OnDestroy. This is more performant for frequently modified shapes as it avoids constant mesh recreation. ```csharp PolylinePath p; void Awake(){ p = new PolylinePath(); p.AddPoint( -1, -1 ); p.AddPoint( -1, 1 ); p.AddPoint( 1, 1 ); p.AddPoint( 1, -1 ); } override void DrawShapes( Camera cam ){ using( Draw.Command( cam ) ){ Draw.Polyline( p, closed:true, thickness:0.1f, Color.red ); // Drawing happens here } } void OnDestroy() => p.Dispose(); // Disposing of mesh data happens here ``` -------------------------------- ### Draw Lines Directly without Draw.Command (C#) Source: https://acegikmo.com/shapes/docs/index Draws lines directly without using Draw.Command, typically for Gizmos. This method bypasses command buffers and issues draw calls immediately. It's less performant due to lack of GPU instancing and requires careful consideration of render pipeline timing. ```csharp void OnDrawGizmos(){ // set up all static parameters. these are used for all following Draw.Line calls Draw.LineGeometry = LineGeometry.Volumetric3D; Draw.ThicknessSpace = ThicknessSpace.Pixels; Draw.Thickness = 4; // 4px wide // draw lines Draw.Line( Vector3.zero, Vector3.right, Color.red ); Draw.Line( Vector3.zero, Vector3.up, Color.green ); Draw.Line( Vector3.zero, Vector3.forward, Color.blue ); } ``` -------------------------------- ### Reset All Shapes.Draw States Source: https://acegikmo.com/shapes/docs/index Completely reset all drawing states, including styling properties and the drawing matrix, back to their default values. This is crucial for ensuring predictable drawing behavior across different drawing commands or sections of code. ```csharp Shapes.Draw.ResetAllDrawStates(); ``` -------------------------------- ### Transform Drawing Space with Shapes.Draw Matrix Source: https://acegikmo.com/shapes/docs/index Control the coordinate space for drawing operations by setting the Draw.Matrix. This allows shapes to be drawn relative to a specific transform, position, rotation, and scale, rather than always using world space. The matrix can be reset to identity. ```csharp // Draw relative to a transform Shapes.Draw.Matrix = transform.localToWorldMatrix; // Draw relative to a specific position, rotation, and scale Shapes.Draw.Matrix = Matrix4x4.TRS(pos, rot, scale); // Reset the matrix to the default identity Shapes.Draw.ResetMatrix(); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.