Version: 2022.3
Physics Profiler 模块
Rendering Profiler 模块

Physics 2D Profiler module

The Physics 2D Profiler module displays information about the physics that the physics system has processed in your project’s scene. This information can help you diagnose and resolve performance issues or unexpected discrepancies related to the physics in your project’s scene.

Physics 2D Profiler window
The Physics 2D Profiler module in the Profiler window

图表类别

The Physics 2D Profiler module’s chart tracks different statistics related to the physics that the physics system processes in the project’s scene, divided into the following chart categories. Click on the frame chart window or select a captured frame in the chart graph to track selected categories. To change the order of the categories in the chart, drag and drop them in the chart’s legend. You can also click a category’s colored legend to toggle its display. Refer to the module details pane for more information about the selected statistics.

Chart 描述
Total Contacts The total number of contacts that were present in this frame. This includes both Collision and Trigger contacts. Processing and solving contacts can be time consuming therefore they should be kept to a minimum.
Total Shapes The total number of physics shapes that were present in this frame. Different Collider2D produce different amounts of physics shapes ranging from one to unlimited. You can get the shape count and retrieve the physics shapes to determine this for any Collider2D.
Total Queries The total number of queries that were called this frame. This includes queries such as Physics2D.Raycast, Physics2D.OverlapPoint etc.
Total Callbacks The total number of OnCollisionEnter2D, OnCollisionStay2D, OnCollisionExit2D, OnTriggerEnter2D, OnTriggerStay2D and OnTriggerExit2D callbacks that were called in this frame.
Total Joints The total number of any Joint2D that were present in this frame.
Total Bodies The total number of Rigidbody2D that were present in this frame.
Awake Bodies The total number of Rigidbody2D that were both awake (not sleeping) and were present in this frame.
Dynamic Bodies The total number of Rigidbody2D with a Dynamic body type that were present in this frame. Dynamic bodies take the most processing of all body types therefore they should be kept to a minimum.
Continuous Bodies The total number of Rigidbody2D with a Continuous collision detection mode that were present in this frame. Continuous bodies are much more expensive than when using Discrete collision detection mode therefore they should be kept to a minimum.
Physics Used Memory The total amount of persistent memory used exclusively by the 2D physics system. This includes both the core engine and the memory used by each physics component, but does not include the temporary memory used in this frame.

Module details pane

When you select a frame in the Physics 2D Profiler module, the details pane displays detailed information about the physics in your project’s scene. The details pane is sorted by category, where each category exists on a single line.

The following reference table describes the statistics available, plus its corresponding profiler counter, and availability in Release builds. The profiler counters are always available in the Editor and Development builds. This information is also available via the ProfilerRecorder API and in the Profiler Module Editor so you can add them to a custom Profiler module.

Physics Used Memory

Statistic 描述 Corresponding Profiler Counter (exact name) Available in Release Players?
Total The total amount of persistent memory used exclusively by the 2D physics system. This includes both the core engine and the memory used by each physics component, but does not include temporary memory used in this frame. Physics Used Memory 2D
Relative The relative percentage of memory used by the 2D physics system compared to the overall memory usage of Unity.

Bodies

Statistic 描述 Corresponding Profiler Counter (exact name) Available in Release Players?
Total The total number of Rigidbody2D that were present in this frame. Total Bodies
Awake The number of Rigidbody2D that were both awake (not sleeping) and were present in this frame. Note that a Rigidbody2D with a Static body type is always asleep. Awake Bodies
Asleep The number of Rigidbody2D that were both sleeping (not awake) and were present in this frame. Note that a Rigidbody2D with a Static body type is always asleep. Asleep Bodies
Dynamic The number of Rigidbody2D with a Dynamic body type that were present in this frame. Dynamic bodies take the most processing of all body types therefore they should be kept to a minimum. Dynamic Bodies
Kinematic The number of Rigidbody2D with a Kinematic body type that were present in this frame. Kinematic bodies have minimal processing therefore they should be used when explicit movement is required but reaction to external forces is not. Kinematic Bodies
Static The number of Rigidbody2D with a Static body type that were present in this frame. Static bodies take the least processing of all body types therefore they should be used when possible where no movement is required. Static Bodies
Discrete The number of Rigidbody2D with a Discrete collision detection mode that were present in this frame. Discrete bodies are far less expensive than when using Continuous collision detection mode therefore they should be used where possible. Discrete Bodies
Continuous The number of Rigidbody2D with a Continuous collision detection mode that were present in this frame. Continuous bodies are much more expensive than when using Discrete collision detection mode therefore they should be kept to a minimum. Continuous Bodies

Shapes

Statistic 描述 Corresponding Profiler Counter (exact name) Available in Release Players?
Total The total number of physics shapes that were present in this frame.. Different Collider2D produce different amounts of physics shapes ranging from one to unlimited. You can get the shape count and retrieve the physics shapes to determine this for any Collider2D. Total Shapes
Awake A physics shape is awake if it is attached to a Rigidbody2D that is awake. This is the number of physics shapes that were both awake (not sleeping) and were present in this frame. Awake Shapes
Asleep A physics shape is asleep if it is attached to a Rigidbody2D that is asleep. This is the number of physics shapes that were both sleeping (not awake) and were present in this frame. Asleep Shapes
Dynamic A physics shape is Dynamic if it is attached to a Rigidbody2D with a Dynamic body type. This is the number of physics shapes that were both Dynamic and were present in this frame. Dynamic Shapes
Kinematic A physics shape is Dynamic if it is attached to a Rigidbody2D with a Kinematic body type. This is the number of physics shapes that were both Kinematic and were present in this frame. Kinematic Shapes
Static A physics shape is Dynamic if it is attached to a Rigidbody2D with a Static body type. This is the number of physics shapes that were both Static and were present in this frame. Static Shapes

Queries

Statistic 描述 Corresponding Profiler Counter (exact name) Available in Release Players?
Total The total number of queries that were called this frame. This includes queries such as Physics2D.Raycast, and Physics2D.OverlapPoint. Total Queries
Raycast The number of ray or line based queries that were called this frame. This includes queries such as Physics2D.Raycast and Physics2D.Linecast. Raycast Queries
Shapecast The number of shape swept queries that were called this frame. This includes queries such as Physics2D.BoxCast, Physics2D.CircleCast, and Collider2D.Cast. Shapecast Queries
Overlap The number of overlap queries that were called this frame. This includes queries such as Physics2D.OverlapPoint, Physics2D.OverlapCircle, and Collider2D.OverlapCollider. Overlap Queries
IsTouching The number of contact touching queries that were called this frame. This includes queries such as Physics2D.IsTouching, Collider2D.IsTouching, Rigidbody2D.IsTouching etc. IsTouching Queries
GetContacts The number of contact retrieval queries that were called this frame. This includes queries such as Physics2D.GetContacts, Collider2D.GetContacts, and Rigidbody2D.GetContacts. Note that this does not include Collision2D.GetContacts which is not a physics query. GetContacts Queries
Particle The number of queries that were called by the particle system in this frame. This is used when the particle system module is configured to contact 2D physics Colliders and is entirely controlled by the particle system. Note that this can become quite high but is also very efficient to process. Particle Queries

Contacts

Statistic 描述 Corresponding Profiler Counter (exact name) Available in Release Players?
Total The total number of contacts that were present in this frame. This includes both Collision and Trigger contacts. Processing and solving contacts can be time consuming therefore they should be kept to a minimum. Total Contacts
Added The number of contacts that were added in this frame. This includes both Collision and Trigger contacts. Adding too many contacts in a single frame can cause performance spikes therefore this should be kept to a minimum. Added Contacts
Removed The number of contacts that were removed in this frame. This includes both Collision and Trigger contacts. Removing contacts is fast and has minimum impact on performance. Removed Contacts
Broadphase Updates The number of broadphase updates that were processed in this frame. A broadphase update occurs when physics shapes are added, removed or change in size. Broadphase updates are used to detect contact changes when two physics shapes potentially overlap and can result in a broadphase pair (see below) being created. Broadphase Updates
Broadphase Pairs The number of broadphase pairs that were processed in this frame. A broadphase pair is created when a broadphase update results in a potential overlap of two physics shapes. A broadphase pair is then processed and the result will be a new contact or it will be ignored if the physics shapes are not configured to contact each other. Broadphase Pairs

Callbacks

Statistic 描述 Corresponding Profiler Counter (exact name) Available in Release Players?
Total The total number of OnCollisionEnter2D, OnCollisionStay2D, OnCollisionExit2D, OnTriggerEnter2D, OnTriggerStay2D and OnTriggerExit2D callbacks that were called in this frame. Total Callbacks
Collision Enter The number of OnCollisionEnter2D callbacks that were called in this frame. Collision Enter
Collision Stay The number of OnCollisionStay2D callbacks that were called in this frame. Collision Stay
Collision Exit The number of OnCollisionExit2D callbacks that were called in this frame. Collision Exit
Trigger Enter The number of OnTriggerEnter2D callbacks that were called in this frame. Trigger Enter
Trigger Stay The number of OnTriggerStay2D callbacks that were called in this frame. Trigger Stay
Trigger Exit The number of OnTriggerExit2D callbacks that were called in this frame. Trigger Exit

Solver

Statistic 描述 Corresponding Profiler Counter (exact name) Available in Release Players?
World Count The total number of physics scene that were present in this frame. Each physics scene contains a physics world that can be simulated independently of any other physics world. Having a large number of worlds is not in of itself a performance issue because it will only occupy memory and not perform any work unless it is simulated. Solver World Count
Simulation Count The number of times all physics scene were simulated either by Unity automatically, by calling Physics2D.Simulate or by directly calling PhysicsScene2D.Simulate. Solver Simulation Count
Discrete Islands An island is a connected graph of bodies connected via mutual joints or mutual contacts. Note that Static body types do not connect islands. The number of contact islands solved when handling the discrete solving step. Solver Discrete Islands
Continuous Islands An island is a connected graph of bodies connected via mutual joints or mutual contacts. Note that Static body types do not connect islands. This is the number of islands solved when handling the continuous solving step. Solving continuous islands is an extremely expensive process and involves multiple iterations that require islands to be regenerated and reprocessed so this should be kept to a minimum. Only a Rigidbody2D with a Continuous collision detection mode will result in this additional continuous island being formed and processed. Solver Continuous Islands

Transform Sync

Statistic 描述 Corresponding Profiler Counter (exact name) Available in Release Players?
Sync Calls The total number of Transform sync calls that were called in this frame. A Transform sync (known as a Transform Read) involves checking to see if any Transforms have changed and if so, the Transform poses are read and cause any Rigidbody2D or Collider2D to be updated. Transforms should not be changed when using physics components however sometimes this is necessary but should be avoided due to potential performance issues if performing too many. Any movements should be performed by using the Rigidbody2D API.

The physics system will perform a single Transform sync as the first part of performing a simulation step so this will always be at least one if a simulation occurred (see Simulation Count above). The physics system will also perform a single Transform sync per-frame if it is handling any Rigidbody2D interpolation.

Additional calls are shown if either Physics2D.AutoSyncTransforms is active (inactive by default) or if Physics2D.SyncTransforms is called although both of these should be avoided as they can both have a severe impact on performance.
Total Transform Sync Calls
Sync Bodies The number of Rigidbody2D that were affected by a Transform sync. This should be kept to a minimum, preferably zero. Transform Sync Bodies
Sync Colliders The number of Collider2D that were affected by a Transform sync. This should be kept to a minimum, preferably zero. Transform Sync Colliders
Parent Sync Bodies The number of Rigidbody2D that were affected by a Transform sync caused by reparenting a Transform.. This should be kept to a minimum, preferably zero. Transform Parent Sync Bodies
Parent Sync Colliders The number of Collider2D that were affected by a Transform sync caused by reparenting a Transform. This should be kept to a minimum, preferably zero. Transform Parent Sync Colliders

Joints

Statistic 描述 Corresponding Profiler Counter (exact name) Available in Release Players?
Total The total number of any Joint2D that were present in this frame. Solving joints can become expensive so these should be kept to a minimum. Total Joints

Timings

Note: All timings are summed over all physics worlds (see World Count). The number of times any timing was sampled is shown in square brackets after the timing itself. Effectively the timing can be divided by the World Count value to give an average time.

Statistic 描述 Corresponding Profiler Counter (exact name) Available in Release Players?
Sim The total amount of time spent handling a full simulation step. This can be called by Unity automatically, by calling Physics2D.Simulate or by directly calling PhysicsScene2D.Simulate. This time includes all the stages involved in completing a simulation step including Transform Sync (read), Calculating Contacts, Integration, Solving Contacts and Joints, Transform Write and Contact Callbacks.
Sync The total amount of time spent processing Transform Sync (see Sync Calls).
Step The total amount of time spent processing simulation steps. This time includes only the core stages involved in completing a simulation step including Calculating Contacts, Integration, Solving Contacts and Joints.
Write The total amount of time spent processing Transform write. This happens during the end of the simulation step where body poses are read and written back to the Transform system.
Callbacks The total amount of time spent processing all callbacks (see Total Callbacks).

Legacy Physics Profiler

You can switch to the Legacy mode to see the older version of the Physics 2D Profiler module, which was the default module in older versions of Unity. To do this, select Legacy from the dropdown menu at the upper-right of the Profiler module’s details pane.

In this mode, you can load and inspect Profiler data that was saved in an older version of Unity. If you switch to this mode to inspect data captured in a newer version of Unity, then the data displayed may be unreliable and inaccurate. It is recommended to always use the Current mode to inspect Physics 2D Profiler data in current versions of Unity.

Legacy Profiler view
Legacy Profiler view
Physics Profiler 模块
Rendering Profiler 模块