NoaScreenshotCallbacks
Configure events related to the screenshot feature.
By passing a class that inherits NoaScreenshotCallbacks to NoaController, you can customize events related to the screenshot feature.
Overridable Members
Methods
| Name | Description |
|---|---|
| OnBeforePrepareScreenshot() | Executed before adjusting NOA Debugger UI visibility according to the ScreenshotTarget described below. By changing ScreenshotTarget here, you can run OnCaptureScreenshot with unwanted NOA Debugger UI hidden. Depending on how the capture is performed, values set here may be overridden later. See ScreenshotTarget Priority for details. |
| OnCaptureScreenshot() | Executed immediately before NOA Debugger’s screenshot process. |
| OnAfterScreenshot() | Executed after the screenshot process. Executed even if NOA Debugger’s screenshot process was not executed. |
Properties
| Name | Description |
|---|---|
| IsAllowBaseScreenshot | Determines whether to execute NOA Debugger’s screenshot process. Default is true; if set to false, the screenshot process is not executed. |
| ScreenshotTarget | Specifies the NOA Debugger UI to preserve as visible during screenshot capture. Default is None, which captures with all NOA Debugger UI hidden. |
Related Types
INoaScreenshotCallbacks
The overridable methods and properties of NoaScreenshotCallbacks are defined in this interface.
If you want to consolidate multiple callback definitions in a custom class, or add callback functionality while inheriting an existing custom class, you can achieve this by using this interface instead of the NoaScreenshotCallbacks class.
NoaController.ScreenshotTarget
A [Flags] enum used by NoaScreenshotCallbacks properties to specify screenshot targets.
Capture with NOA Debugger UI not included in the targets hidden.
| Item | Description |
|---|---|
| None | Capture with all NOA Debugger UI hidden. Note: Because other flags take precedence, use None by itself. |
| LaunchButton | Include launch button in the capture targets. |
| FloatingWindows | Include floating windows in the capture targets. |
| MainView | Include main view in the capture targets. |
| Overlays | Include overlays in the capture targets. |
| Controller | Include the controller in the capture targets. |
| All | Include all NOA Debugger UI in the capture targets. |
ScreenshotTarget Priority
ScreenshotTarget can be set in more than one way; the value that applies is resolved using the following priority order.
Lower numbers indicate higher priority.
| Priority | Source | When it applies |
|---|---|---|
| 1 | ScreenshotTarget selected in the screenshot settings dialog | When capturing from the dialog, or when Override in the dialog is enabled |
| 2 | ScreenshotTarget passed as an argument to CaptureScreenshot | When the method is called with an argument. Does not apply when Override in the dialog is enabled |
| 3 | ScreenshotTarget set in OnBeforePrepareScreenshot | When a callback is registered |
Note: ScreenshotTarget set in OnBeforePrepareScreenshot has the lowest priority and may be overridden by an argument or settings dialog configuration.
Sample Code
#if NOA_DEBUGGER
using NoaDebugger;
using UnityEngine;
// Example of executing events before and after NOA Debugger’s screenshot process.
public class ExampleScreenshotManager : NoaScreenshotCallbacks
{
NoaController.ScreenshotTarget target;
public override NoaController.ScreenshotTarget ScreenshotTarget => target;
public override void OnBeforePrepareScreenshot()
{
// Example of changing whether to include NOA Debugger UI in the screenshot depending on the current scene.
if (ExampleSceneManager.Instance.CurrentScene == SceneType.Battle)
{
target = NoaController.ScreenshotTarget.FloatingWindows | NoaController.ScreenshotTarget.Overlays;
}
else
{
target = NoaController.ScreenshotTarget.None;
}
}
public override void OnAfterScreenshot()
{
byte[] data = NoaController.GetCapturedScreenshot();
if (data != null)
{
// Example of saving the image data to a file.
string filePath = Application.persistentDataPath + "/screenshot.png";
System.IO.File.WriteAllBytes(filePath, data);
Debug.Log($"Screenshot saved to: {filePath}");
// Clear the captured screenshot image.
NoaController.ClearCapturedScreenshot();
}
else
{
Debug.LogError("No screenshot data.");
}
}
}
// Example of executing a custom process without executing NOA Debugger’s screenshot process.
public class ExampleOriginalScreenshotManager : NoaScreenshotCallbacks
{
// Set IsAllowBaseScreenshot to false to prevent execution of NOA Debugger’s screenshot process.
public override bool IsAllowBaseScreenshot => false;
// Because the default display-control process is triggered, you can execute your custom capture process with NOA Debugger UI hidden.
public override void OnCaptureScreenshot()
{
ScreenCapture.CaptureScreenshot("screenshot.png");
}
}
#endif
