文档

Unity Engine

Unity Engine

Physics Core 2D Profiler module reference

Explore the statistics in the Physics Core 2D Profiler module to find how many objects 2D Physics Core simulates and how much time each part of the simulation takes.
阅读时间5 分钟最后更新于 3 天前

The Physics Core 2D module in the Profiler window displays the number of physics objects in the 2D Physics Core worlds in your project, the memory the simulation uses, and the time each stage of the simulation step takes.
The module displays data for the frame you select in the chart.
注意
This documentation is about using Pose, Area, and Constraint components. To use 2D physics in the Unity Editor using components like the Rigidbody 2D component, refer to 2D physics instead.
To enable the Profiler module, follow these steps:
  1. In the main menu, go to Window > Analysis > Profiler.
  2. Select Profiler Modules, then enable Physics Core 2D.
To collect profiling data, enter Play mode, or build your application with the Profiler attached. For more information, refer to Collecting performance data.

Chart categories

The chart in the Physics Core 2D module displays the following categories. Each value is the total for all the physics worlds in the selected frame.

Chart

Description

Total WorldsDisplays the number of physics worlds. The total includes the default world. For more information, refer to Create multiple simulation worlds with 2D Physics Core.
Total BodiesDisplays the number of physics bodies.
Total ShapesDisplays the number of physics shapes attached to bodies.
Total ContactsDisplays the number of contacts between pairs of shapes that are touching or close to touching.
Total JointsDisplays the number of constraints that connect bodies. For more information, refer to Introduction to constraints.
Total IslandsDisplays the number of islands. An island is a group of bodies that contacts or constraints connect, which Unity simulates together. The total includes islands that are asleep. An island falls asleep when every body in the island moves slower than its Sleep Threshold value for 0.5 seconds. Unity doesn't simulate a sleeping island until a collision or force wakes up one of its bodies. For more information, refer to Physics Simulation Definition asset reference.
Total Stack UsedDisplays the largest amount of temporary stack memory that each world has needed for a simulation step since Unity created the world, added together for all worlds.
Total Memory UsedDisplays the amount of memory that 2D Physics Core currently allocates.
Total TasksDisplays the number of tasks that Unity splits the simulation step into, to run them on worker threads. For more information, refer to Optimize 2D Physics Core with multithreading.

Module details pane

The details pane of the Physics Core 2D module contains the Physics Core 2D Statistics panel and the Physics Core 2D Profile Data panel.

Physics Core 2D Statistics

The Physics Core 2D Statistics panel displays the counts and memory use of 2D Physics Core in the selected frame. Each value is the total for all the physics worlds. The panel displays memory values with the unit B, KB, or MB, where 1 KB is 1,024 bytes and 1 MB is 1,024 KB.
To control whether the details pane follows the frame you select, enable the Live Update checkbox in the Physics Core 2D Statistics panel. Live Update is enabled by default.
  • When you enable Live Update, both panels display the data for the frame you select in the chart.
  • When you disable Live Update, both panels keep the data they currently display, even when you select another frame or Unity records new frames. When you enable Live Update again, both panels display the data for the frame you select.
The Physics Core 2D Statistics panel contains the following properties:

Property

Description

BodiesDisplays the number of physics bodies.
ShapesDisplays the number of physics shapes attached to bodies.
ContactsDisplays the number of contacts between pairs of shapes that are touching or close to touching.
JointsDisplays the number of constraints that connect bodies.
IslandsDisplays the number of islands. The total includes islands that are asleep.
Stack UsedDisplays the largest amount of temporary stack memory that each world has needed for a simulation step, added together for all worlds.
Memory UsedDisplays the amount of memory that 2D Physics Core currently allocates.
TasksDisplays the number of tasks that Unity splits the simulation step into, to run them on worker threads.
Broadphase HeightDisplays the height of the tree that Unity uses to find which shapes on dynamic and kinematic bodies might overlap, added together for all worlds. A higher value means Unity needs more steps to search the tree.
Static Broadphase HeightDisplays the height of the tree that Unity uses to find which shapes on static bodies might overlap, added together for all worlds. A higher value means Unity needs more steps to search the tree.

Physics Core 2D Profile Data

The Physics Core 2D Profile Data panel displays a table of the time 2D Physics Core spends on each part of the simulation in the selected frame. The Name column displays the name of each row, and the Time column displays the time in milliseconds (ms).
The time of a row includes the time of the rows beneath it. To expand or collapse a row, select the arrow next to it, or double-click the row. To sort the table, select a column heading.
If the selected frame has no data, the panel displays a message that prompts you to select another frame.
The Physics Core 2D Profile Data panel contains the following property:

Property

Description

View BySets how the table groups the time. The following options are available:
  • Physics World: Displays a row for each physics world, with the time that world spends on its simulation step. Expand a world to display the stages of its simulation step, for example collision detection and the solver. If a world doesn't have a name, the row displays it as World # and a number.
  • Physics World (Combined): Displays the same stages as Physics World, with the time of all the physics worlds added together.
  • Physics Profiler Timing: Displays the time that the main thread spends on 2D Physics Core methods. Each row groups the methods of one type, for example PhysicsShape. Expand a type to display the time of each method. Methods that don't belong to a type are in the Miscellaneous row.

Additional resources