Version: 2022.3

ProfilerMarkerConstructor

切换到手册
public ProfilerMarker (string name);
public ProfilerMarker (Unity.Profiling.ProfilerCategory category, string name);
public ProfilerMarker (Unity.Profiling.ProfilerCategory category, char* name, int nameLen);
public ProfilerMarker (Unity.Profiling.ProfilerCategory category, string name, Unity.Profiling.LowLevel.MarkerFlags flags);
public ProfilerMarker (Unity.Profiling.ProfilerCategory category, char* name, int nameLen, Unity.Profiling.LowLevel.MarkerFlags flags);
public ProfilerMarker (char* name, int nameLen);

参数

name 标记名称。
category Profiler category.
nameLen Marker name length.
flags The marker flags.

描述

为代码检测构造一个新的性能标记。

使用 ProfilerMarker 为 Profiler 和 Recorder 标记一段代码。

using Unity.Profiling;

public class MySystemClass { static readonly ProfilerMarker s_PreparePerfMarker = new ProfilerMarker("MySystem.Prepare"); static readonly ProfilerMarker s_SimulatePerfMarker = new ProfilerMarker(ProfilerCategory.Ai, "MySystem.Simulate");

public void UpdateLogic() { s_PreparePerfMarker.Begin(); // ... s_PreparePerfMarker.End();

using (s_SimulatePerfMarker.Auto()) { // ... } } }