Draw a debug visualization of LowLevelPhysics2D API objects
Configure how Unity draws 2D physics objects in the Unity Editor or at runtime, and draw your own shapes.
Read time 2 minutesLast updated 9 days ago
To help you visualize 2D physics objects during development, Unity automatically draws the shapes you create with the API.
LowLevelPhysics2DUnity draws the shapes automatically in the Unity Editor. You can also enable Unity drawing the shapes in development builds.

An image from the sandbox demo of the PhysicsCore2D repository on GitHub. Thousands of tiny multi-colored capsules are scattered around an area dotted with 2D shapes, with boundaries represented by gray boxes.
Configure debug drawing
Unity draws your shapes automatically in the Scene view, the Game view, and when you enter Play mode.
To configure debug drawing, follow these steps:
- Select the GameObject with a public component. For more information, refer to Create a physics world.
PhysicsWorldDefinition - In the window, configure the properties that start withInspector
?
. For exampleDrawselects which features to draw, andDraw Optionssets the colors Unity uses.Draw Colors
To set a different color for a specific shape, follow these steps:
- Select a GameObject with a public component. For more information, refer to Create a physics object.
PhysicsShapeDefinition - In the Inspector window, set Custom Color.
To configure the properties in your C# script instead, adjust the similarly named properties of your , , or objects.
PhysicsWorldDefinitionPhysicsBodyDefinitionPhysicsShapeDefinitionEnable debug drawing in a development build
To draw in a Player build, follow these steps:
- Make sure your target build platform supports compute shaders.
- Create a Physics Low Level Settings 2D asset. For more information, refer to Configure global 2D physics settings.
- In the Inspector window of the asset, enable Draw In Build.
Draw your own shapes
To draw your own shapes, use the methods of the world object. For example:
Draw// Get the main physics world.PhysicsWorld world = PhysicsWorld.defaultWorld;// Draw a line from the origin to (30, 40) in "cornflower blue".world.DrawLine(Vector2.zero, new Vector2(30f, 40f), Color.cornflowerBlue);// Draw a circle from the origin to (30, 40) in "forest green".world.DrawCircle(new Vector2(30f, 40f), 2f, Color.forestGreen);// Draw a point with a 3 pixel radius at (-5, 10) in "gold".world.DrawPoint(new Vector2(-5f, 10f), 3f, Color.gold);
Shapes only last for one frame. To draw them for longer, use the lifetime property.
// Set lifetime as 5 seconds.const float lifeTime = 5f;// Draw a circle at a specific position in blue for 5 seconds.world.DrawGeometry(circleGeometry, physicsTransform, Color.cornflowerBlue, lifeTime);