UITKMeshDrawSink
public class UITKMeshDrawSink : IChartDrawSinkChartGuru.IChartDrawSink that writes into a UI Toolkit
UnityEngine.UIElements.MeshGenerationContext. Accepts the full ChartGuru.DrawTopology
surface by internally wrapping itself in a ChartGuru.TopologyAdapter so the
renderer can emit quads, line lists, and line strips even though
UnityEngine.UIElements.MeshGenerationContext only accepts indexed triangles.
The sink keeps a CPU-side transform stack (`ChartGuru.UITKMeshDrawSink.PushTransform(UnityEngine.Matrix4x4)` /
`ChartGuru.UITKMeshDrawSink.PopTransform`) matching GL.MultMatrix semantics and applies a
Y-flip at vertex emission so the chart's bottom-left coordinate system maps to UI
Toolkit's top-left origin. Batches are flushed per `ChartGuru.UITKMeshDrawSink.Begin(ChartGuru.DrawTopology%2cChartGuru.DrawMaterial)`/`ChartGuru.UITKMeshDrawSink.End`
pair into a single MeshGenerationContext.Allocate(int, int) call.
The v1 pipeline does not support the full 720+ primitive sites of the existing
`ChartGuru.ChartRenderer` - those still emit through GL. [ChartGuru.ChartGuruElement](/tools/chartguru/api/chartguru-chartguruelement/)
therefore uses a camera-backed `UnityEngine.RenderTexture` blit as the v1 rendering
strategy and only opens this sink at the top of its generateVisualContent
callback to paint a single textured quad. Once the inner sites are migrated, the
same sink carries native geometry.
Constructors
Section titled “Constructors”
UITKMeshDrawSink()
Section titled “UITKMeshDrawSink()”public UITKMeshDrawSink()Methods
Section titled “Methods”
Configure(MeshGenerationContext, Vector2, float)
Section titled “Configure(MeshGenerationContext, Vector2, float)”public UITKMeshDrawSink Configure(MeshGenerationContext ctx, Vector2 contentSize, float lineWidth = 1)Binds the sink to a live UnityEngine.UIElements.MeshGenerationContext. Must be called
at the top of the generateVisualContent callback before routing the
renderer through this sink.
Parameters
| Name | Type |
|---|---|
ctx |
UnityEngine.UIElements.MeshGenerationContext |
contentSize |
UnityEngine.Vector2 |
lineWidth |
System.Single |
Returns
ChartGuru.UITKMeshDrawSink
EmitTexturedQuad(Texture, Rect, Color)
Section titled “EmitTexturedQuad(Texture, Rect, Color)”public void EmitTexturedQuad(Texture texture, Rect rectPoints, Color tint)Optional convenience: emit a single textured quad covering the content rect. Used by ChartGuru.ChartGuruElement’s v1 RT blit path.
Parameters
| Name | Type |
|---|---|
texture |
UnityEngine.Texture |
rectPoints |
UnityEngine.Rect |
tint |
UnityEngine.Color |
Begin(DrawTopology, DrawMaterial)
Section titled “Begin(DrawTopology, DrawMaterial)”public void Begin(DrawTopology topology, DrawMaterial material = DrawMaterial.Standard)Begins a primitive batch with the given topology and material bucket.
Must be balanced with ChartGuru.IChartDrawSink.End before another ChartGuru.IChartDrawSink.Begin(ChartGuru.DrawTopology%2cChartGuru.DrawMaterial).
Parameters
| Name | Type |
|---|---|
topology |
ChartGuru.DrawTopology |
material |
ChartGuru.DrawMaterial |
Color(Color)
Section titled “Color(Color)”public void Color(Color c)Sets the current vertex color. Applies to all subsequently emitted vertices until overridden.
Parameters
| Name | Type |
|---|---|
c |
UnityEngine.Color |
Vertex(float, float)
Section titled “Vertex(float, float)”public void Vertex(float x, float y)Emits a vertex at the specified chart-space pixel coordinate (Y up, bottom-left origin).
Parameters
| Name | Type |
|---|---|
x |
System.Single |
y |
System.Single |
public void End()Closes the current primitive batch started by ChartGuru.IChartDrawSink.Begin(ChartGuru.DrawTopology%2cChartGuru.DrawMaterial).
SetScissor(Rect?)
Section titled “SetScissor(Rect?)”public void SetScissor(Rect? clipRectPixels)Sets an axis-aligned scissor rectangle in pixel coordinates, or clears it when null.
Intended for morph and inset panels; the GL sink translates this to an SRP scissor,
the UI Toolkit sink to a clipping descendant or manual CPU-side clipping.
Parameters
| Name | Type |
|---|---|
clipRectPixels |
System.Nullable{UnityEngine.Rect} |
PushTransform(Matrix4x4)
Section titled “PushTransform(Matrix4x4)”public void PushTransform(Matrix4x4 m)Pushes a transform onto the sink’s matrix stack. Subsequent ChartGuru.IChartDrawSink.Vertex(System.Single%2cSystem.Single)
calls are effectively multiplied by the top-of-stack matrix.
Matches GL.PushMatrix + GL.MultMatrix(m).
Parameters
| Name | Type |
|---|---|
m |
UnityEngine.Matrix4x4 |
PopTransform()
Section titled “PopTransform()”public void PopTransform()Pops the top matrix from the sink’s transform stack. Matches GL.PopMatrix.