Skip to content

Game.GizmosExt

Assembly: Game (Game.dll)
Namespace: Game

Type: static class

Base: System.Object

Summary:
Extension helper methods for GizmoBatcher that make it easy to draw Curve objects (Cities: Skylines 2 Curve type) without manually extracting the underlying bezier and length fields. Provides simple overloads for drawing plain curves, directional curves (with arrow heads), and flow curves (animated or multiple arrows).


Fields

  • This type defines no instance fields.
    {{ The class is a static extension container and does not hold state. It simply forwards calls to existing GizmoBatcher.Draw... overloads using the Curve's internal bezier (m_Bezier) and length (m_Length) members. }}

Properties

  • This type defines no properties.
    {{ As a static extension class there are no properties to expose. }}

Constructors

  • No public constructors (static class)
    {{ GizmosExt is a static class and cannot be instantiated. It only contains static extension methods. }}

Methods

  • public static void DrawCurve(this GizmoBatcher batcher, Curve curve, Color color, int segmentsCount = -1)
    {{ Extension method that draws the provided Curve by delegating to batcher.DrawCurve(curve.m_Bezier, curve.m_Length, color, segmentsCount). The optional segmentsCount controls how many line segments are used to approximate the curve; a value of -1 uses the default/automatic segmentation provided by the underlying method. Use this to render the curve outline in the specified color. }}

  • public static void DrawDirectionalCurve(this GizmoBatcher batcher, Curve curve, Color color, bool reverse = false, int segmentsCount = -1, float arrowHeadLength = 0.4f, float arrowHeadAngle = 25f, int circleSegmentsCount = 16)
    {{ Extension method that draws the Curve with directional markers (arrow heads and end circles). Internally forwards to batcher.DrawDirectionalCurve(curve.m_Bezier, curve.m_Length, ...). Parameters:

  • reverse: if true, arrows are drawn in the opposite direction along the curve.
  • segmentsCount: optional segmentation for curve approximation (-1 = automatic).
  • arrowHeadLength: length of arrow head in world units (default 0.4).
  • arrowHeadAngle: spread angle of the arrow head in degrees (default 25).
  • circleSegmentsCount: number of segments to use when drawing end circles (default 16). Use this to indicate direction or flow on a path. }}

  • public static void DrawFlowCurve(this GizmoBatcher batcher, Curve curve, Color color, float timeOffset = 0f, bool reverse = false, int arrowCount = 2, int segmentsCount = 16, float arrowHeadLength = 0.4f, float arrowHeadAngle = 25f, int circleSegmentsCount = 16)
    {{ Extension method that draws the Curve with repeating directional arrows to indicate flow along the curve. It forwards to batcher.DrawFlowCurve(curve.m_Bezier, curve.m_Length, ...). Parameters:

  • timeOffset: offset used for animating moving arrows along the curve (can be Time.time or a custom offset).
  • reverse: invert arrow direction.
  • arrowCount: how many arrows to draw along the curve.
  • segmentsCount: segmentation used to approximate the curve for drawing (default 16 here).
  • arrowHeadLength, arrowHeadAngle, circleSegmentsCount: same meaning as in DrawDirectionalCurve. Useful for visualizing moving traffic, flow, or other directional data along a spline. }}

Usage Example

using Game; // for GizmosExt
using UnityEngine;

public class MyGizmoDrawer : MonoBehaviour
{
    public GizmoBatcher batcher;
    public Curve curve;

    void OnDrawGizmos()
    {
        if (batcher == null || curve == null) return;

        // Simple curve
        batcher.DrawCurve(curve, Color.green);

        // Directional curve with custom arrow size
        batcher.DrawDirectionalCurve(curve, Color.yellow, reverse: false, arrowHeadLength: 0.5f);

        // Flow curve with animated arrows (use Time.time for animation)
        batcher.DrawFlowCurve(curve, Color.cyan, timeOffset: Time.time * 0.5f, arrowCount: 3, segmentsCount: 24);
    }
}

{{ Notes: - These methods are thin convenience wrappers—the real drawing behavior is implemented by the GizmoBatcher overloads that accept a bezier and a length. The wrappers extract curve.m_Bezier and curve.m_Length from the provided Curve instance and forward the call. - Because these are extension methods in the Game namespace, ensure you have "using Game;" (or reference the Game namespace) where you call them. - Default parameter values match those in the source; adjust them to fit your visual needs (e.g., more segments for smoother curves, larger arrowHeadLength for visibility). }}