# EmitFrameMetaData

> Write metadata associated with the current frame to the Profiler stream.

## Definition

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

## EmitFrameMetaData(Guid, int, Array)

Write metadata associated with the current frame to the Profiler stream.

```csharp
[Conditional("ENABLE_PROFILER")]
public static void EmitFrameMetaData(Guid id, int tag, Array data)
```

### Parameters

**** (\[Guid]\(https\://learn.microsoft.com/dotnet/api/system.guid)): Module identifier. Used to distinguish metadata streams between different plugins, packages or modules.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Data stream index.**** (\[Array]\(https\://learn.microsoft.com/dotnet/api/system.array)): Binary data.

### Remarks

Use *EmitFrameMetaData* to write arbitrary binary data to the profiler stream. Data must contain only blittable types.

```csharp
using System;
using System.Diagnostics;
using Unity.Collections;
using UnityEngine;
using UnityEngine.Profiling;

public class Example
{
    public struct TextureInfo
    {
        public int format;
        public int w;
        public int h;
    }

    public static readonly Guid MyProjectId = new Guid("7E1DEA84-51F1-477A-82B5-B5C57AC1EBF7");
    public static readonly int TextureInfoTag = 0;
    public static readonly int TextureDataTag = 1;

    [Conditional("ENABLE_PROFILER")]
    public void EmitTextureToProfilerStream(Texture2D t)
    {
        if (!Profiler.enabled)
            return;
        TextureInfo textureInfo = new TextureInfo() { format = (int)t.format, w = t.width, h = t.height };
        NativeArray<byte> textureData = t.GetRawTextureData<byte>();
        Profiler.EmitFrameMetaData(MyProjectId, TextureInfoTag, new[] { textureInfo });
        Profiler.EmitFrameMetaData(MyProjectId, TextureDataTag, textureData);
    }
}
```

Check whether [Profiler.enabled](/engine/6000.7/script-reference/unityengine/profiling/profiler/enabled.md) is `true` and, if you use a [ProfilerCategory](/engine/6000.7/script-reference/unity/profiling/profilercategory.md), whether [Profiler.IsCategoryEnabled](/engine/6000.7/script-reference/unityengine/profiling/profiler/iscategoryenabled.md) returns `true`, before you generate and send metadata. This avoids unnecessary overhead when the Profiler is disabled.

```csharp
if (Profiler.enabled && Profiler.IsCategoryEnabled(myCategory))
{
    Profiler.EmitFrameMetaData(...);
}
```

**Note:**

Writing large chunks of data might increase the Profiler's overhead and memory usage. Always check if Profiler is [Profiler.enabled](/engine/6000.7/script-reference/unityengine/profiling/profiler/enabled.md) before generating data. When possible, write data in small chunks to reduce memory usage.

Additional Resources: [FrameDataView.GetFrameMetaData](/engine/6000.7/script-reference/unityeditor/profiling/framedataview/getframemetadata.md).

## EmitFrameMetaData\<T>(Guid, int, List\<T>)

Write metadata associated with the current frame to the Profiler stream.

```csharp
[Conditional("ENABLE_PROFILER")]
public static void EmitFrameMetaData<T>(Guid id, int tag, List<T> data) where T : struct
```

### Parameters

**** (\[Guid]\(https\://learn.microsoft.com/dotnet/api/system.guid)): Module identifier. Used to distinguish metadata streams between different plugins, packages or modules.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Data stream index.**** (\[List\<T>]\(https\://learn.microsoft.com/dotnet/api/system.collections.generic.list-1)): Binary data.

### Remarks

Use *EmitFrameMetaData* to write arbitrary binary data to the profiler stream. Data must contain only blittable types.

```csharp
using System;
using System.Diagnostics;
using Unity.Collections;
using UnityEngine;
using UnityEngine.Profiling;

public class Example
{
    public struct TextureInfo
    {
        public int format;
        public int w;
        public int h;
    }

    public static readonly Guid MyProjectId = new Guid("7E1DEA84-51F1-477A-82B5-B5C57AC1EBF7");
    public static readonly int TextureInfoTag = 0;
    public static readonly int TextureDataTag = 1;

    [Conditional("ENABLE_PROFILER")]
    public void EmitTextureToProfilerStream(Texture2D t)
    {
        if (!Profiler.enabled)
            return;
        TextureInfo textureInfo = new TextureInfo() { format = (int)t.format, w = t.width, h = t.height };
        NativeArray<byte> textureData = t.GetRawTextureData<byte>();
        Profiler.EmitFrameMetaData(MyProjectId, TextureInfoTag, new[] { textureInfo });
        Profiler.EmitFrameMetaData(MyProjectId, TextureDataTag, textureData);
    }
}
```

Check whether [Profiler.enabled](/engine/6000.7/script-reference/unityengine/profiling/profiler/enabled.md) is `true` and, if you use a [ProfilerCategory](/engine/6000.7/script-reference/unity/profiling/profilercategory.md), whether [Profiler.IsCategoryEnabled](/engine/6000.7/script-reference/unityengine/profiling/profiler/iscategoryenabled.md) returns `true`, before you generate and send metadata. This avoids unnecessary overhead when the Profiler is disabled.

```csharp
if (Profiler.enabled && Profiler.IsCategoryEnabled(myCategory))
{
    Profiler.EmitFrameMetaData(...);
}
```

**Note:**

Writing large chunks of data might increase the Profiler's overhead and memory usage. Always check if Profiler is [Profiler.enabled](/engine/6000.7/script-reference/unityengine/profiling/profiler/enabled.md) before generating data. When possible, write data in small chunks to reduce memory usage.

Additional Resources: [FrameDataView.GetFrameMetaData](/engine/6000.7/script-reference/unityeditor/profiling/framedataview/getframemetadata.md).

## EmitFrameMetaData\<T>(Guid, int, NativeArray\<T>)

Write metadata associated with the current frame to the Profiler stream.

```csharp
[Conditional("ENABLE_PROFILER")]
public static void EmitFrameMetaData<T>(Guid id, int tag, NativeArray<T> data) where T : struct
```

### Parameters

**** (\[Guid]\(https\://learn.microsoft.com/dotnet/api/system.guid)): Module identifier. Used to distinguish metadata streams between different plugins, packages or modules.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Data stream index.**** (\[NativeArray\<T>]\(/engine/6000.7/script-reference/unity/collections/nativearray1)): Binary data.

### Remarks

Use *EmitFrameMetaData* to write arbitrary binary data to the profiler stream. Data must contain only blittable types.

```csharp
using System;
using System.Diagnostics;
using Unity.Collections;
using UnityEngine;
using UnityEngine.Profiling;

public class Example
{
    public struct TextureInfo
    {
        public int format;
        public int w;
        public int h;
    }

    public static readonly Guid MyProjectId = new Guid("7E1DEA84-51F1-477A-82B5-B5C57AC1EBF7");
    public static readonly int TextureInfoTag = 0;
    public static readonly int TextureDataTag = 1;

    [Conditional("ENABLE_PROFILER")]
    public void EmitTextureToProfilerStream(Texture2D t)
    {
        if (!Profiler.enabled)
            return;
        TextureInfo textureInfo = new TextureInfo() { format = (int)t.format, w = t.width, h = t.height };
        NativeArray<byte> textureData = t.GetRawTextureData<byte>();
        Profiler.EmitFrameMetaData(MyProjectId, TextureInfoTag, new[] { textureInfo });
        Profiler.EmitFrameMetaData(MyProjectId, TextureDataTag, textureData);
    }
}
```

Check whether [Profiler.enabled](/engine/6000.7/script-reference/unityengine/profiling/profiler/enabled.md) is `true` and, if you use a [ProfilerCategory](/engine/6000.7/script-reference/unity/profiling/profilercategory.md), whether [Profiler.IsCategoryEnabled](/engine/6000.7/script-reference/unityengine/profiling/profiler/iscategoryenabled.md) returns `true`, before you generate and send metadata. This avoids unnecessary overhead when the Profiler is disabled.

```csharp
if (Profiler.enabled && Profiler.IsCategoryEnabled(myCategory))
{
    Profiler.EmitFrameMetaData(...);
}
```

**Note:**

Writing large chunks of data might increase the Profiler's overhead and memory usage. Always check if Profiler is [Profiler.enabled](/engine/6000.7/script-reference/unityengine/profiling/profiler/enabled.md) before generating data. When possible, write data in small chunks to reduce memory usage.

Additional Resources: [FrameDataView.GetFrameMetaData](/engine/6000.7/script-reference/unityeditor/profiling/framedataview/getframemetadata.md).
