Version: 2023.2
LanguageEnglish
  • C#

MemoryProfiler.TakeSnapshot

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 TakeSnapshot(string path, Action<string,bool> finishCallback, Unity.Profiling.Memory.CaptureFlags captureFlags);

Declaration

public static void TakeSnapshot(string path, Action<string,bool> finishCallback, Action<string,bool,DebugScreenCapture> screenshotCallback, Unity.Profiling.Memory.CaptureFlags captureFlags);

Parameters

path Destination path for the memory snapshot file.
finishCallback Event that is fired once the memory snapshot has finished the process of capturing data.
captureFlags Flag mask defining the content of the memory snapshot.
screenshotCallback Event that you can specify to retrieve a screenshot after the snapshot has finished.

Description

Triggers a memory snapshot capture.

Request a memory snapshot capture with the provided arguments. Not all fields corresponding to the capture flags are collected. This depends on the target build used to capture the snapshot. In the system, there are two different behaviors of data collection:

* When you call this directly from the Player or in the Editor, the process synchronously creates the memory snapshot file on the host device.Note: This requires that there's no profiling target connected. Metadata collection happens if at least one collection fallback was registered to MemoryProfiler.CreatingMetadata. At the end of the process, MemoryProfiler.SnapshotFinished is triggered.

* When you call this in an Editor, and you have connected to a profiling target, the process asynchronously creates the memory snapshot file on the host device and sends the capture request to the remote target. The target device then collects meta data using the callbacks registered to MemoryProfiler.CreatingMetadata. You must define the callbacks in the profiling target's local assemblies and register them at run time before you send the capture event. All captured data is streamed to the Editor from the remote target. When the capture process is complete, the snapshot finished callback is triggered inside the Editor. If a screenshot callback was provided during the call, this is called at the end of the current frame.

Note: * Screenshot callbacks are only called in standalone players or in Play mode.

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