Version: 2020.1
LanguageEnglish
  • C#
Experimental: this API is experimental and might be changed or removed in the future.

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

public static void TakeSnapshot(string path, Action<string,bool> finishCallback, Profiling.Memory.Experimental.CaptureFlags captureFlags);
public static void TakeSnapshot(string path, Action<string,bool> finishCallback, Action<string,bool,DebugScreenCapture> screenshotCallback, Profiling.Memory.Experimental.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 screengrab 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. Meta data collection happens if at least one collection fallback was registered to MemoryProfiler.CreateMetaData. 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.CreateMetaData. 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.

对文档有任何疑问,请移步至开发者社区提问,我们将尽快为您解答