Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


ProfilerMarkerData

Describes Profiler metadata parameter that can be associated with a sample.
Read time 1 minuteLast updated 12 days ago

Definition

public struct ProfilerMarkerData

Remarks

Used with ProfilerUnsafeUtility.BeginSampleWithMetadata method. The ProfilerMarkerData.Type value defines the data type ProfilerMarkerData.Ptr points to. The value must be a ProfilerMarkerDataType enum value.

Examples

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); }}

Fields

Value

Description

PtrRaw pointer to the metadata value.
SizeSize of the metadata value in bytes.
TypeMetadata type.