# GetRecorder()

> Returns Recorder associated with the Sampler.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine.Profiling](/engine/6000.0/script-reference/unityengine/profiling.md)
* **Assembly:** UnityEngine.CoreModule

```csharp
public Recorder GetRecorder()
```

### Returns

| Type                                                                          | Description                                                                                                       |
| ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- |
| [Recorder](/engine/6000.0/script-reference/unityengine/profiling/recorder.md) | [Recorder](/engine/6000.0/script-reference/unityengine/profiling/recorder.md) 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.

```csharp
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](/engine/6000.0/script-reference/unityengine/profiling/sampler/isvalid.md) to verify if Sampler can be used to create a valid Recorder.

Additional Resources: [Sampler.isValid](/engine/6000.0/script-reference/unityengine/profiling/sampler/isvalid.md), [Recorder](/engine/6000.0/script-reference/unityengine/profiling/recorder.md), [Recorder.isValid](/engine/6000.0/script-reference/unityengine/profiling/recorder/isvalid.md).
