Version: 2023.2
public bool enabled ;

描述

启用录制。

启用后,无论性能分析器是否已启用,录制器都会收集数据。

Note:
Set to false to make measurements available immediately for synchronous testing scenarious.

using UnityEngine;
using UnityEngine.Profiling;

public class Example { public static void TimeSynchronousMethodWithMarkers() { var recorder = Recorder.Get("MyMarker"); recorder.enabled = true; // Starts measurements

// Call method which uses MyMarker // MyMethod();

recorder.enabled = false; // Stops measurements and makes data available immediately Debug.Log("MyMarker total time, ns: " + recorder.elapsedNanoseconds); } }