Version: 2021.2
public void Begin ();
public void Begin (Object contextUnityObject);

参数

contextUnityObject 与操作关联的对象。

描述

开始分析标有此 ProfilerMarker 实例所定义的自定义名称的一段代码。

始终使用 End 来结束已检测代码的已开始部分。\ 标有 BeginEnd 的代码将显示在 Profiler 层级视图中。 使用 Recorder 来获取 Player 中的每帧时序。

__注意:__.BeginEnd 具有线程安全性,可以在作业化的代码中使用。

using Unity.Profiling;

public class MySystemClass { static ProfilerMarker s_PreparePerfMarker = new ProfilerMarker("MySystem.Prepare");

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

Begin 是使用 ConditionalAttribute 按条件编译的。 因此,在非开发版中部署时,它的开销为零。

另请参阅:ProfilerMarker.EndRecorderProfilerCPU

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961