NoaSnapshot
Through this class, you can execute controls from the script, such as obtaining logs held by the Snapshot function, capturing logs, mass disposal of logs, and resetting the elapsed time.
APIs
Static Methods
API | Description |
---|---|
ClearLogsAndTimer() | Disposes of all logs and resets the elapsed time. |
CaptureLog(label, backgroundColor, hasNoaProfilerInfo, additionalInfo) | Captures the log. Specifies the label and background color to set for the log, whether or not it holds profiler information provided by NOA Debugger, and additional information as parameters. |
Static Properties
API | Description |
---|---|
LogList | Returns a list of the log information it retains. |
OnLogCopied | This event is triggered when a log is copied to the clipboard. |
OnLogDownload | This event is triggered when a log is downloaded. If the event handler returns true, the logs will be downloaded locally. If the event handler returns false, the logs will not be downloaded. |
Sample Code
using System.Collections.Generic;
using UnityEngine;
#if NOA_DEBUGGER
using NoaDebugger;
#endif
public class Example
{
void ExampleMethod()
{
#if NOA_DEBUGGER
// Get a list of log information retained by the Snapshot function.
List<SnapshotLogRecordInformation> snapshotLogList = NoaSnapshot.LogList;
// Dispose of all logs and reset elapsed time.
NoaSnapshot.ClearLogsAndTimer();
// Capture the log.
NoaSnapshot.CaptureLog("label", NoaSnapshot.BgColor.Blue, hasNoaProfilerInfo: true);
// Create a Directory for additional information.
var additionalInfo = new Dictionary<string,NoaSnapshotCategory>();
// Set additional information without specifying a category.
var category = new NoaSnapshotCategory();
// Item 1 for each category.
var categoryItem1 = new NoaSnapshotCategoryItem
(
key: "SampleKey",
value: "SampleValue",
color: NoaSnapshot.FontColor.Black
);
category.Add(categoryItem1);
// Item 2 for each category.
var categoryItem2 = new NoaSnapshotCategoryItem
(
key: "SampleKey",
value: "SampleValue2",
color: NoaSnapshot.FontColor.Black
);
// Overwrite the value and color when the key is duplicated.
category.Add(categoryItem2);
// If no key is specified, it will be managed as an item of Others.
additionalInfo[""] = category;
// Set additional information by specifying a category.
// Additional information for Category 1.
var category1 = new NoaSnapshotCategory();
var category1Item = new NoaSnapshotCategoryItem
(
key: "SampleKey",
value: "SampleValue",
color: NoaSnapshot.FontColor.Black
);
category1.Add(category1Item);
additionalInfo["Category1"] = category1;
// Capture a log including additional information.
NoaSnapshot.CaptureLog("label", NoaSnapshot.BgColor.Blue, hasNoaProfilerInfo: true, additionalInfo);
// Set up the event that is triggered when a log is copied to the clipboard
NoaSnapshot.OnLogCopied += (SnapshotLogRecordInformation log, string clipboardText) => Debug.Log($"Log copied. Clipboard: {clipboardText}");
// Set up the event that is triggered when a log is downloaded
NoaSnapshot.OnLogDownload += (string filename, string jsonData) =>
{
Debug.Log($"Logs download. Filename: {filename}");
// Return true to allow local download
// Return false to prevent local download
return true;
};
#endif
}
}