Recorder 与采样器关联的 Recorder 对象。
返回与采样器关联的 Recorder。
每个采样器只有一个录制器。对 GetRecorder 的多次调用将返回可控制同一本机录制器对象的引用。 如果采样器对象无效,也会返回无效的录制器对象。
using UnityEngine;
using UnityEngine.Profiling;
public class ExampleClass : MonoBehaviour
{
Recorder behaviourUpdateRecorder;
void Start()
{
var sampler = Sampler.Get("BehaviourUpdate");
behaviourUpdateRecorder = sampler.GetRecorder();
if (behaviourUpdateRecorder.isValid)
behaviourUpdateRecorder.enabled = true;
}
void Update()
{
if (behaviourUpdateRecorder.isValid)
Debug.Log("BehaviourUpdate time: " + behaviourUpdateRecorder.elapsedNanoseconds);
}
}
注意:目前,采样器仅在 Editor 和 Development Player 中可用。使用 Sampler.isValid 可验证采样器是否可用于创建有效的录制器。
另请参阅:Sampler.isValid、Recorder、Recorder.isValid。