SetMarkerMetadata
Set Profiler marker metadata name and type.
読み終わるまでの所要時間 2 分最終更新 1ヶ月前
Definition
- Type: Method
- Namespace: Unity.Profiling.LowLevel.Unsafe
- Assembly: UnityEngine.CoreModule
SetMarkerMetadata(IntPtr, int, string, byte, byte)
Set Profiler marker metadata name and type.
public static void SetMarkerMetadata(nint markerPtr, int index, string name, byte type, byte unit)
Parameters
Remarks
Use to add additional usage context to the Profiler sample metadata parameter.
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, ProfilerMarkerDataUnit.
SetMarkerMetadata(IntPtr, int, char*, int, byte, byte)
Set Profiler marker metadata name and type.
public static void SetMarkerMetadata(nint markerPtr, int index, char* name, int nameLen, byte type, byte unit)
Parameters
Remarks
Use to add additional usage context to the Profiler sample metadata parameter.
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, ProfilerMarkerDataUnit.