EmitSessionMetaData
Write metadata associated with the whole Profiler session capture.
Read time 4 minutesLast updated 7 days ago
Definition
- Type: Method
- Namespace: UnityEngine.Profiling
- Assembly: UnityEngine.CoreModule
EmitSessionMetaData(Guid, int, Array)
Write metadata associated with the whole Profiler session capture.
[Conditional("ENABLE_PROFILER")]public static void EmitSessionMetaData(Guid id, int tag, Array data)
Parameters
Remarks
Use EmitSessionMetaData to write arbitrary binary data that should be available for all frames of this session. Data must contain only blittable types.
If the information you want to store in the Profiler meta data might change from frame to frame, consider using Profiler.EmitFrameMetaData instead.
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.EmitSessionMetaData(MyProjectId, TextureInfoTag, new[] { textureInfo }); Profiler.EmitSessionMetaData(MyProjectId, TextureDataTag, textureData); }}
Make sure that Profiler.enabled is before you send session-wide metadata, so that the metadata is serialized to the data stream.
trueif (Profiler.enabled && Profiler.IsCategoryEnabled(myCategory)){ Profiler.EmitSessionMetaData(...);}
Note:
Writing large chunks of data might increase the Profiler's overhead and memory usage. Always check if Profiler is Profiler.enabled before generating data. When possible, write data in small chunks to reduce memory usage.
Additional Resources: FrameDataView.GetSessionMetaData.
EmitSessionMetaData<T>(Guid, int, List<T>)
Write metadata associated with the whole Profiler session capture.
[Conditional("ENABLE_PROFILER")]public static void EmitSessionMetaData<T>(Guid id, int tag, List<T> data) where T : struct
Parameters
Remarks
Use EmitSessionMetaData to write arbitrary binary data that should be available for all frames of this session. Data must contain only blittable types.
If the information you want to store in the Profiler meta data might change from frame to frame, consider using Profiler.EmitFrameMetaData instead.
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.EmitSessionMetaData(MyProjectId, TextureInfoTag, new[] { textureInfo }); Profiler.EmitSessionMetaData(MyProjectId, TextureDataTag, textureData); }}
Make sure that Profiler.enabled is before you send session-wide metadata, so that the metadata is serialized to the data stream.
trueif (Profiler.enabled && Profiler.IsCategoryEnabled(myCategory)){ Profiler.EmitSessionMetaData(...);}
Note:
Writing large chunks of data might increase the Profiler's overhead and memory usage. Always check if Profiler is Profiler.enabled before generating data. When possible, write data in small chunks to reduce memory usage.
Additional Resources: FrameDataView.GetSessionMetaData.
EmitSessionMetaData<T>(Guid, int, NativeArray<T>)
Write metadata associated with the whole Profiler session capture.
[Conditional("ENABLE_PROFILER")]public static void EmitSessionMetaData<T>(Guid id, int tag, NativeArray<T> data) where T : struct
Parameters
Unique identifier associated with the data.
Data stream index.
Binary data.
Remarks
Use EmitSessionMetaData to write arbitrary binary data that should be available for all frames of this session. Data must contain only blittable types.
If the information you want to store in the Profiler meta data might change from frame to frame, consider using Profiler.EmitFrameMetaData instead.
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.EmitSessionMetaData(MyProjectId, TextureInfoTag, new[] { textureInfo }); Profiler.EmitSessionMetaData(MyProjectId, TextureDataTag, textureData); }}
Make sure that Profiler.enabled is before you send session-wide metadata, so that the metadata is serialized to the data stream.
trueif (Profiler.enabled && Profiler.IsCategoryEnabled(myCategory)){ Profiler.EmitSessionMetaData(...);}
Note:
Writing large chunks of data might increase the Profiler's overhead and memory usage. Always check if Profiler is Profiler.enabled before generating data. When possible, write data in small chunks to reduce memory usage.
Additional Resources: FrameDataView.GetSessionMetaData.