Version: 2023.2
public static void SetMarkerMetadata (IntPtr markerPtr, int index, string name, byte type, byte unit);
public static void SetMarkerMetadata (IntPtr markerPtr, int index, char* name, int nameLen, byte type, byte unit);

参数

markerPtr Profiler marker handle.
index Metadata parameter index.
name Metadata parameter name.
type Metadata type. Must be one of ProfilerMarkerDataType values.
unit Metadata unit. Must be one of ProfilerMarkerDataUnit values.
nameLen Metadata parameter name length.

描述

Set Profiler marker metadata name and type.

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); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961