How to scale Draw.Text() in Immediate-Mode Drawing?

  • updated

Hi there,

I work on an application, where one can draw lines and each line has a measure text, which shows its length in Meter. Everything is drawn using the “Immediate-Mode Drawing”.

To scale the placed lines and their points (discs) I use something like the pseudo-code below. But the text is not scaled (see screenshots).

Is there another Draw-Property to set? Maybe something like “Draw.TextFontSpace” or do you know of another possibility to scale Draw.Text()?

public void Enable ()
    RenderPipelineManager.beginCameraRendering += DrawShapes;

private void DrawShapes(ScriptableRenderContext context, Camera cam)
    using (Draw.Command(cam))
        // scales all thicknesses and radius according to the set sizes in pixel
        // see example from documentation
        Draw.ThicknessSpace = ThicknessSpace.Pixels;
        Draw.RadiusSpace = ThicknessSpace.Pixels;

        // draw lines and points (using discs)
        // is scaled
        // draw measure Text
        // >>> text is not scaled <<<

Image 714

Image 715

Best regards,

Reporting a bug? please specify Unity version:
Reporting a bug? please specify Shapes version:
Reporting a bug? please specify Render Pipeline:
Built-in render pipeline
Freya Holmér creator

There's no built-in pixel sizing option for text at the moment, you'll have to scale it manually with Draw.Scale or Draw.FontSize, based on whatever heuristic you want to use


Alright, thanks for the reply and thanks a lot for making Shapes. It is a great asset :).
Is something like this planned in the near future (next 2-3 months)?

Freya Holmér creator

pixel-based text scaling is not planned - it's using text-mesh pro shaders, so I don't have as much control over them on the shader side of things!


I see. Then I will do the text scaling probably based on closest-text--to-camera-distance.
Thanks for your help.