Version: 2019.4
LanguageEnglish
  • C#

Profiler.EmitFrameMetaData

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public static void EmitFrameMetaData(Guid id, int tag, Array data);

Declaration

public static void EmitFrameMetaData(Guid id, int tag, List<T> data);

Declaration

public static void EmitFrameMetaData(Guid id, int tag, NativeArray<T> data);

Parameters

id Module identifier. Used to distinguish metadata streams between different plugins, packages or modules.
tag Data stream index.
data Binary data.

Description

Write metadata associated with the current frame to the Profiler stream.

Use EmitFrameMetaData to write arbitrary binary data to the profiler stream. Data must contain only blittable types.

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 kMyProjectId = new Guid("7E1DEA84-51F1-477A-82B5-B5C57AC1EBF7"); public static readonly int kTextureInfoTag = 0; public static readonly int kTextureDataTag = 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.EmitFrameMetaData(kMyProjectId, kTextureInfoTag, new[] { textureInfo }); Profiler.EmitFrameMetaData(kMyProjectId, kTextureDataTag, textureData); } }

Note:
Writing large chunks of data might increase profiler overhead and memory usage. Always check if Profiler is enabled before generating data. When possible, write data in small chunks to reduce memory usage.

See Also: HierarchyFrameDataView.GetFrameMetaData.

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