Version: 2021.3

AutoScope

struct in Unity.Profiling

切换到手册

描述

与 ProfilerMarker.Auto 结合使用的 helper IDisposable 结构。

使用 ProfilerMarker.Auto 将要在 using 语句中分析的一段代码包裹起来。AutoScope 的构造函数调用 ProfilerMarker.Begin 和 Dispose 方法 - ProfilerMarker.Begin。

using Unity.Profiling;

public class MySystemClass { ProfilerMarker simulatePerfMarker = new ProfilerMarker("MySystem.Simulate");

public void UpdateLogic() { using (simulatePerfMarker.Auto()) { // ... } } }