Immediate Mode Not Working

Avatar
  • updated
  • Answered

I cannot get the immediate mode to draw using the doc example. I've re installed (after deleting my Library) as well.

Image 646

[ExecuteAlways]
public class PowerNode : ImmediateModeShapeDrawer
{
    public override void OnEnable() => Camera.onPostRender += DrawShapes;

    public override void OnDisable() => Camera.onPostRender -= DrawShapes;

    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 = 20; // 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);
        }

    }
}
Reporting a bug? please specify Unity version:
2021.3.6f1
Reporting a bug? please specify Shapes version:
4.2.1
Reporting a bug? please specify Render Pipeline:
URP
Avatar
Freya Holmér creator

you're overriding OnEnable/OnDisable, using a camera event that doesn't work in URP. remove your overrides and it should work!

Avatar
Freya Holmér creator
  • Answered