# SetMarkerMetadata

> Set Profiler marker metadata name and type.

## Definition

* **Type:** Method
* **Namespace:** [Unity.Profiling.LowLevel.Unsafe](/engine/6000.7/script-reference/unity/profiling/lowlevel/unsafe.md)
* **Assembly:** UnityEngine.CoreModule

## SetMarkerMetadata(IntPtr, int, string, byte, byte)

Set Profiler marker metadata name and type.

```csharp
public static void SetMarkerMetadata(nint markerPtr, int index, string name, byte type, byte unit)
```

### Parameters

**** (\[IntPtr]\(https\://learn.microsoft.com/dotnet/api/system.intptr)): Profiler marker handle.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Metadata parameter index.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Metadata parameter name.**** (\[byte]\(https\://learn.microsoft.com/dotnet/api/system.byte)): Metadata type. Must be one of ProfilerMarkerDataType values.**** (\[byte]\(https\://learn.microsoft.com/dotnet/api/system.byte)): Metadata unit. Must be one of ProfilerMarkerDataUnit values.

### Remarks

Use to add additional usage context to the Profiler sample metadata parameter.

```csharp
using Unity.Collections.LowLevel.Unsafe;
using Unity.Profiling;
using Unity.Profiling.LowLevel;
using Unity.Profiling.LowLevel.Unsafe;
using System;

class Example
{
    static IntPtr MakeMarkerWithIntMetadata(string name, string paramName)
    {
        var handle = ProfilerUnsafeUtility.CreateMarker(name, ProfilerUnsafeUtility.CategoryScripts, MarkerFlags.Default, 1);
        ProfilerUnsafeUtility.SetMarkerMetadata(handle, 0, paramName, (byte)ProfilerMarkerDataType.Int32, (byte)ProfilerMarkerDataUnit.Count);
        return handle;
    }

    static readonly IntPtr markerHandle = MakeMarkerWithIntMetadata("MyMarker", "Work Idx");
    static unsafe void DoWork(int num)
    {
        var metadata = stackalloc ProfilerMarkerData[1];
        metadata[0].Type = (byte)ProfilerMarkerDataType.Int32;
        metadata[0].Size = (uint)UnsafeUtility.SizeOf<int>();
        metadata[0].Ptr = UnsafeUtility.AddressOf(ref num);
        ProfilerUnsafeUtility.BeginSampleWithMetadata(markerHandle, 1, metadata);
        //...
        ProfilerUnsafeUtility.EndSample(markerHandle);
    }
}
```

Additional Resources: [ProfilerMarkerDataType](/engine/6000.7/script-reference/unity/profiling/lowlevel/profilermarkerdatatype.md), [ProfilerMarkerDataUnit](/engine/6000.7/script-reference/unity/profiling/profilermarkerdataunit.md).

## SetMarkerMetadata(IntPtr, int, char\*, int, byte, byte)

Set Profiler marker metadata name and type.

```csharp
public static void SetMarkerMetadata(nint markerPtr, int index, char* name, int nameLen, byte type, byte unit)
```

### Parameters

**** (\[IntPtr]\(https\://learn.microsoft.com/dotnet/api/system.intptr)): Profiler marker handle.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Metadata parameter index.**** (\[char\*]\(https\://learn.microsoft.com/dotnet/api/system.char)): Metadata parameter name.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Metadata parameter name length.**** (\[byte]\(https\://learn.microsoft.com/dotnet/api/system.byte)): Metadata type. Must be one of ProfilerMarkerDataType values.**** (\[byte]\(https\://learn.microsoft.com/dotnet/api/system.byte)): Metadata unit. Must be one of ProfilerMarkerDataUnit values.

### Remarks

Use to add additional usage context to the Profiler sample metadata parameter.

```csharp
using Unity.Collections.LowLevel.Unsafe;
using Unity.Profiling;
using Unity.Profiling.LowLevel;
using Unity.Profiling.LowLevel.Unsafe;
using System;

class Example
{
    static IntPtr MakeMarkerWithIntMetadata(string name, string paramName)
    {
        var handle = ProfilerUnsafeUtility.CreateMarker(name, ProfilerUnsafeUtility.CategoryScripts, MarkerFlags.Default, 1);
        ProfilerUnsafeUtility.SetMarkerMetadata(handle, 0, paramName, (byte)ProfilerMarkerDataType.Int32, (byte)ProfilerMarkerDataUnit.Count);
        return handle;
    }

    static readonly IntPtr markerHandle = MakeMarkerWithIntMetadata("MyMarker", "Work Idx");
    static unsafe void DoWork(int num)
    {
        var metadata = stackalloc ProfilerMarkerData[1];
        metadata[0].Type = (byte)ProfilerMarkerDataType.Int32;
        metadata[0].Size = (uint)UnsafeUtility.SizeOf<int>();
        metadata[0].Ptr = UnsafeUtility.AddressOf(ref num);
        ProfilerUnsafeUtility.BeginSampleWithMetadata(markerHandle, 1, metadata);
        //...
        ProfilerUnsafeUtility.EndSample(markerHandle);
    }
}
```

Additional Resources: [ProfilerMarkerDataType](/engine/6000.7/script-reference/unity/profiling/lowlevel/profilermarkerdatatype.md), [ProfilerMarkerDataUnit](/engine/6000.7/script-reference/unity/profiling/profilermarkerdataunit.md).
