Legacy Documentation: Version 5.6 (Go to current version)
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Recorder

class in UnityEngine.Profiling

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

Records profiling data produced by a specific Sampler.

Recorder accumulates elapsed time of every Begin/End pair during a frame. Once enabled it sums delta time between Begin and End samples produced by a Sampler. Use elapsedNanoseconds to get the accumulated time for the previous frame.

#pragma strict
var behaviourUpdateRecorder: Recorder;
function Start() {
	behaviourUpdateRecorder = Recorder.Get("BehaviourUpdate");
	behaviourUpdateRecorder.enabled = true;
}
function Update() {
	if (behaviourUpdateRecorder.isValid)
		Debug.Log("BehaviourUpdate time: " + behaviourUpdateRecorder.elapsedNanoseconds);
}
using UnityEngine;
using UnityEngine.Profiling;

public class ExampleClass : MonoBehaviour { Recorder behaviourUpdateRecorder; void Start() { behaviourUpdateRecorder = Recorder.Get("BehaviourUpdate"); behaviourUpdateRecorder.enabled = true; }

void Update() { if (behaviourUpdateRecorder.isValid) Debug.Log("BehaviourUpdate time: " + behaviourUpdateRecorder.elapsedNanoseconds); } }

Note: A Recorder collects data regardless of the Profiler state. When a Recorder is enabled, data is accumulated every time its Sampler is hit. This information is equivalent to the one you can see in Hierarchy view in the Profiler Window.

At the moment Samplers are available only in the Editor and Development Players. Use Recorder.isValid to verify if Recorder can collect the data.

See Also: Sampler, Recorder.isValid, [[Recorder::elapsedNanoseconds]].

Variables

elapsedNanosecondsAccumulated time of Begin/End pairs for the previous frame in nanoseconds. (Read Only)
enabledEnables recording.
isValidReturns true if Recorder is valid and can collect data. (Read Only)
sampleBlockCountNumber of time Begin/End pairs was called during the previous frame. (Read Only)

Static Functions

GetUse this function to get a Recorder for the specific Profiler label.