# Draw a debug visualization of Physics Core 2D API objects

> Configure how Unity draws 2D physics objects in the Unity Editor or at runtime, and draw your own shapes.

> **Note:**
>
> This documentation is about writing C# scripts using the `Unity.U2D.Physics` API. To use 2D physics in the Unity Editor using components like the Rigidbody 2D component, refer to [2D physics](/engine/6000.6/manual/unity2d/2d-physics.md.md) instead.

To help you visualize 2D physics objects during development, Unity automatically draws the shapes you create with the Physics Core 2D API.

Unity draws the shapes automatically in the Unity Editor. You can also enable Unity drawing the shapes in 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.:**
![](/api/media?file=/engine/6000.6/media/images/2d-physics-api-debug-draw.png)

## 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:

1. Select the GameObject with a public `PhysicsWorldDefinition` component. For more information, refer to [Create a physics world](/engine/6000.6/manual/unity2d/2d-physics-api/create-objects/world.md).
2. In the Editor window, configure the properties that start with `Draw`. For example `Draw Options` selects which features to draw, and `Draw Colors` sets the colors Unity uses.

To set a different color for a specific shape, follow these steps:

1. Select a GameObject with a public `PhysicsShapeDefinition` component. For more information, refer to [Create a physics object](/engine/6000.6/manual/unity2d/2d-physics-api/create-objects/physics-object.md).
2. In the **Inspector** window, set **Custom Color**.

To configure the properties in your C# script instead, adjust the similarly named properties of your [`PhysicsWorldDefinition`](/engine/6000.6/script-reference/unity/u2d/physics/physicsworlddefinition.md), [`PhysicsBodyDefinition`](/engine/6000.6/script-reference/unity/u2d/physics/physicsbodydefinition.md), or [`PhysicsShapeDefinition`](/engine/6000.6/script-reference/unity/u2d/physics/physicsshapedefinition.md) objects.

## Enable debug drawing in a development build

To draw in a build, follow these steps:

1. Make sure your target build platform supports [compute shaders](/engine/6000.6/manual/materials-and-shaders/shaders/writing-custom/class-compute-shader/introduction.md).
2. Create and assign a Physics Core Settings 2D asset. For more information, refer to [Configure global 2D physics settings](/engine/6000.6/manual/unity2d/2d-physics-api/properties/class-physics-core-settings2d.md).
3. In the Editor window, select **PhysicsCore 2D** > **Settings**.
4. Set **Rendering Mode** to **Development Player** or **Any Player**.

## Draw your own shapes

To draw your own shapes, use the `Draw` methods of the [world object](/engine/6000.6/script-reference/unity/u2d/physics/physicsworld.md). For example:

```csharp
// 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.

```csharp
// 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);
```

## Additional resources

* [Creating physics objects with the Physics Core 2D API](/engine/6000.6/manual/unity2d/2d-physics-api/create-objects.md)
* [PhysicsCore2D repository](https://github.com/Unity-Technologies/PhysicsExamples2D/tree/master) on GitHub
* [World definition reference for the Physics Core 2D API](/engine/6000.6/manual/unity2d/2d-physics-api/reference/world.md)
* [PhysicsCore 2D reference](/engine/6000.6/manual/unity-editor/editor-settings-reference/comp-manager-group/class-physics-core2dproject-settings.md)
