Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


GetRecorder()

Returns Recorder associated with the Sampler.
Read time 1 minuteLast updated 5 days ago

Definition

public Recorder GetRecorder()

Returns

Type

Description

RecorderRecorder object associated with the Sampler.

Remarks

Each Sampler has only one recorder. Multiple calls to GetRecorder return references that control the same native Recorder object. If Sampler object is invalid, it returns invalid Recorder object as well.
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); }}
Note: At the moment Samplers are available only in the Editor and Development Players. Use Sampler.isValid to verify if Sampler can be used to create a valid Recorder.
Additional Resources: Sampler.isValid, Recorder, Recorder.isValid.