Version: 2017.3
Контроллеры персонажа (Character Controllers)
Справка по 3D физике

Physics Debug Visualization

Physics Debug Visualiser allows you to quickly inspect the Collider geometry in your Scene, and profile common physics-based scenarios. It provides a visualisation of which GameObjects should and should not collide with each other. This is particularly useful when there are many Colliders in your Scene, or if the Render and Collision Meshes are out of sync.

For further guidance on improving physics performance in your project, see documentation on the Physics Profiler.

To open the Physics Debug window in the Unity Editor, go to Window > Physics Debugger.

Default Physics Debug Visualization settings and a Cube primitive
Default Physics Debug Visualization settings and a Cube primitive

From this window, you can customize visual settings and specify the types of GameObjects you want to see or hide in the visualizer.

Physics Debug window with fold-out options and overlay panel
Physics Debug window with fold-out options and overlay panel
The Physics Debug overlay panel
The Physics Debug overlay panel

Hide Selected Items is the default mode. This means that every item appears in the visualizer, and you need to tick the checkbox for each item to hide it. To change this to Show Selected Items, use the drop-down at the top of the window. This means that no items appear in the visualizer, and you need to tick the checkbox for each item to display it.

Property Function
Reset Click this button to reset the Physics Debug window back to default settings.
Hide Layers Use the dropdown menu to determine whether or not to display Colliders from the selected Layers.
Hide Static Colliders Tick this checkbox to remove static Colliders (Colliders with no Rigidbody component) from the visualization.
Hide Triggers Tick this checkbox to remove Colliders that are also Triggers from the visualization.
Hide Rigidbodies Tick this checkbox to remove Rigidbody components from the visualization.
Hide Kinematic Bodies Tick this checkbox to remove Colliders with Kinematic Rigidbody components (which are not controlled by the physics engine) from the visualization. See documentation on Rigidbody components for more details.
Hide Sleeping Bodies Tick this checkbox to remove Colliders with Sleeping Rigidbody components (which are not currently engaging with the physics engine) from the visualization. See documentation on Rigidbody components: Sleeping for more details.
Collider Types Use these options to remove specific Collider types from the physics visualization.
    Hide
    BoxColliders
Tick this checkbox to remove Box Colliders from the visualization.
    Hide
    SphereColliders
Tick this checkbox to remove Sphere Colliders from the visualization.
    Hide
    CapsuleColliders
Tick this checkbox to remove Capsule Colliders from the visualization.
    Hide
    MeshColliders
    (convex)
Tick this checkbox to remove convex Mesh Colliders from the visualization.
    Hide
    MeshColliders
    (concave)
Tick this checkbox to remove concave Mesh Colliders from the visualization.
    Hide
    TerrainColliders
Tick this checkbox to remove Terrain Colliders from the visualization.
Hide None Click Hide None to clear all filtering criteria and display all Collider types in the visualization.
Hide All Click Hide All to enable all filters and remove all Collider types from the visualization.
Colors Use these settings to define how Unity displays physics components in the visualization.
    Static
    Colliders
Use this color selector to define which color indicates static Colliders (Colliders with no Rigidbody component) in the visualization.
    Triggers Use this color selector to define which color indicates Colliders that are also Triggers in the visualization.
    Rigidbodies Use this color selector to define which color indicates Rigidbody components in the visualization.
    Kinematic
    Bodies
Use this color selector to define which color indicates Kinematic Rigidbody components (which are not controlled by the physics engine) from the visualization. See documentation on Rigidbody components for more details.
    Sleeping
    Bodies
Use this color selector to define which color indicates Sleeping Rigidbody components (which are not currently engaging with the physics engine) from the visualization. See documentation on Rigidbody components: Sleeping for more details.
    Variation Use the slider to set a value between 0 and 1. This defines how much of your chose color blends with a random color. Use this to visually separate Colliders by color, and to see the structure of the GameObjects.
Rendering Use these settings to define how Unity renders and displays the physics visualization.
    Transparency Use the slider to set the value between 0 and 1. This defines the transparency of drawn collision geometry in the visualization.
    Force
    Overdraw
Normal render geometry can sometimes obscure Colliders (for example, a Mesh Collider plane underneath a floor).Tick the Force Overdraw checkbox to make the visualization renderer draw Collider geometry on top of render geometry.
    View
    Distance
Use this to set the view distance of the visualization.
    Terrain
    Tiles Max
Use this to set the maximum number of Terrain tiles in the visualization.

The overlay panel has further options:

The Physics Debug overlay panel
The Physics Debug overlay panel
Property Function
Collision Geometry Tick this checkbox to enable collision geometry visualization.
Mouse Select Tick this checkbox to enable mouse-over highlighting and mouse selection. This can be useful if you have large GameObjects obstructing each other in the visualizer.

Profiling

You can use Physics Debug to profile and troubleshoot physics activity in your game. You can customize which types of Colliders or Rigidbody components you can see in the visualiser, to help you find the source of activity. The two most helpful are:

To see active Rigidbody components only: To see only the Rigidbody components that are active and therefore using CPU/GPU resources, tick Hide Static Colliders and Hide Sleeping Bodies.

To see non-convex Mesh Colliders only: Non-convex (triangle-based) Mesh Colliders tend to generate the most contacts when their attached Rigidbody components are very near a collision with another Rigidbody or Collider. To visualize only the non-convex Mesh Colliders, set the window to Show Selected Items mode, click the Select None button, then tick the Show MeshColliders (concave) checkbox.

Scripting API Reference

See Unity Scripting API Reference for:



  • 2017–06–01 Page amended with editorial review

  • Physics Debug Visualization is a new feature in Unity 5.6

Контроллеры персонажа (Character Controllers)
Справка по 3D физике