NoaDebuggerNoaDebugger
  • v1.6.0
  • v1.5.0
  • v1.4.0
  • v1.3.0
  • v1.2.0
  • v1.1.0
  • v1.0.0
Demo
Contact
Buy
  • 日本語
  • English
  • 日本語
  • English
  • 日本語
  • English
  • 日本語
  • English
  • 日本語
  • English
  • 日本語
  • English
  • 日本語
  • English
  • v1.6.0
  • v1.5.0
  • v1.4.0
  • v1.3.0
  • v1.2.0
  • v1.1.0
  • v1.0.0
Demo
Contact
Buy
  • 日本語
  • English
  • 日本語
  • English
  • 日本語
  • English
  • 日本語
  • English
  • 日本語
  • English
  • 日本語
  • English
  • 日本語
  • English
  • NoaController

NoaController

Through this class, you can control the various operations on the controller from the script.

APIs

Static Methods

APIDescription
Show()Shows the controller.
Hide()Hides the controller.
SetCustomTapAction(buttonIndex, action, messageFunc)Sets the action to be performed when a custom action button (0-4) on the controller is pressed.
If messageFunc is omitted, a default toast message is displayed. If null is returned, no toast message is displayed.
SetCustomLongPressAction(buttonIndex, action, messageFunc)Sets the action to be performed when a custom action button (0-4) on the controller is long pressed.
If messageFunc is omitted, a default toast message is displayed. If null is returned, no toast message is displayed.
SetCustomToggleAction(buttonIndex, action, messageFunc, initialState)Sets the action to be performed when a custom action button (0-4) on the controller is toggled.
If messageFunc is omitted, a default toast message is displayed. If null is returned, no toast message is displayed.
The initialState parameter specifies the initial toggle state and defaults to false if omitted.
SetCustomActionType(buttonIndex, actionType)Switches the function of a custom action button (0-4) on the controller.
The following functions can be set:
- NoaController.CustomActionType.Button: Becomes a button that triggers an action when pressed or long pressed. This is the default setting if no setting is made.
- NoaController.CustomActionType.ToggleButton: Becomes a toggle button.
GetCustomActionType(buttonIndex)Gets the action type set for a custom action button (0-4) on the controller. Returns CustomActionType.Default if no action is registered.
RunCustomTapAction(buttonIndex)Executes the action set for when a custom action button (0-4) on the controller is pressed. If no press action is set, nothing happens.
RunCustomLongPressAction(buttonIndex)Executes the action set for when a custom action button (0-4) on the controller is long pressed. If no long press action is set, nothing happens.
SetCustomToggle(buttonIndex, isOn)Toggles the custom action button (0-4) on the controller. If no toggle action is set, nothing happens.
GetCustomToggle(buttonIndex)Returns the toggle state of the custom action button (0-4) on the controller. If no toggle action is set, it returns false.
TogglePauseResume()Toggles the game state between paused and resumed.
IncreaseGameSpeed()Increases the game speed.
DecreaseGameSpeed()Decreases the game speed.
MinimizeGameSpeed()Sets the game speed to its minimum value.
MaximizeGameSpeed()Sets the game speed to its maximum value.
FrameStepping()Pause the game and stepping frame by frame.
ResetGameSpeed()Resets the game speed to default.
ResetApplication()Transitions to the application initial scene. You can cancel the process by returning a specific value from the callback that is invoked before transition.
ToggleNoaDebuggerUI()Toggles the show state of the NOA Debugger-related UI. You can cancel the process by returning a specific value from the callback that is invoked before toggle.
CaptureScreenshot()Captures a screenshot. In cases where a screenshot is captured during a crash, the process may not work correctly because the rendering may not be complete.
GetCapturedScreenshot()Returns the captured screenshot or null if there is no captured screenshot.
ClearCapturedScreenshot()Clears the captured screenshot.

Static Properties

APIDescription
OnShowCallback that is fired when the controller is displayed.
OnHideCallback that is fired when the controller is closed.
OnTogglePauseResumeCallback that is fired when the game state is toggled between paused and resumed. You can get the game playing state when the callback is fired.
OnGameSpeedChangedCallback that is fired when the game speed is changed. You can get the changed game speed when the callback is fired.
OnApplicationResetCallback that is fired when the application reset from the tool. If the callback returns true, the application transitions to the initial scene, otherwise, if it returns false, the transition does not occur.
OnToggleNoaDebuggerUICallback that is fired when toggling the show state of the NOA Debugger-related UI. If the callback returns true, toggle is executed, otherwise, if it returns false, toggle will not occur.
OnBeforeScreenshotCallback that is fired before capturing a screenshot. The return value of the callback controls the contents of the screenshot.
The return value should specify a combination of the following flags:
- NoaController.ScreenshotTarget.All: Includes all NOA Debugger-related UI.
- NoaController.ScreenshotTarget.LaunchButton: Includes the launch button.
- NoaController.ScreenshotTarget.FloatingWindows: Includes floating windows.
- NoaController.ScreenshotTarget.UIElement: Includes NoaUIElement.
- NoaController.ScreenshotTarget.MainView: Includes the main view.
- NoaController.ScreenshotTarget.Overlay: Includes overlays.
- NoaController.ScreenshotTarget.None: Does not include any NOA Debugger-related UI.
OnCaptureScreenshotCallback that is fired when capturing a screenshot. If the callback returns true, capturing a screenshot is executed, otherwise, if it returns false, capturing a screenshot will not occur and GetCapturedScreenshot() returns null.
OnAfterScreenshotCallback that is fired after capturing a screenshot. You can get the captured screenshot image by GetCapturedScreenshot() inside this callback or at a timing after the callback is called. This is fired even if OnCaptureScreenshot returns false, but the image data returned by GetCapturedScreenshot() will be null.
OnFrameSteppingCallback that is fired when stepping frames with the tool.
IsVisibleReturns true if the controller is displayed.
IsGamePlayingReturns true if the game is playing, false if game is paused.
GameSpeedReturns the game speed set by the tool.

Sample Code

using UnityEngine;
#if NOA_DEBUGGER
using NoaDebugger;
#endif

public class Example
{
    void ExampleMethod()
    {
#if NOA_DEBUGGER
        // Show the controller.
        NoaController.Show();

        // Hide the controller.
        NoaController.Hide();

        // Set the callback that is fired when the controller is displayed.
        NoaController.OnShow = () => Debug.Log("Show controller.");

        // Set the callback that is fired when the controller is closed.
        NoaController.OnHide = () => Debug.Log("Hide controller.");

        // Check if the controller is displayed.
        bool isControllerVisible = NoaController.IsVisible;

        // Set the action to be performed when the custom action button #0 on the controller is tapped.
        // The default toast message is displayed when custom action button #0 is tapped.
        NoaController.SetCustomTapAction(0, () => Debug.Log("Controller #0 tapped"));

        // Execute the action set for when the custom action button #0 on the controller is tapped.
        NoaController.RunCustomTapAction(0);

        // Set the action to be performed when the custom action button #0 on the controller is long pressed.
        // No toast message is displayed when custom action button #0 is long pressed.
        NoaController.SetCustomLongPressAction(0, () => Debug.Log("Controller #0 long pressed"), () => null);

        // Execute the action set for when the custom action button #0 on the controller is long pressed.
        NoaController.RunCustomLongPressAction(0);

        // Set the action to be performed when the custom action button #1 on the controller is toggled.
        // The specified toast message is displayed when custom action button #1 is toggled.
        // Since custom action buttons are set to function on press or long press by default, you need to set it to function as a toggle button.
        NoaController.SetCustomActionType(1, NoaController.CustomActionType.ToggleButton);

        // Get the action type of the custom action button
        CustomActionType actionType = NoaController.GetCustomActionType(0);

        // This toggle starts from the Off state
        NoaController.SetCustomToggleAction(
            1,
            isOn => Debug.Log($"Controller #1 toggled: {isOn}"),
            isOn => $"Controller #1 toggled: {isOn}",
            false);

        // Toggle the custom action button #1 on the controller.
        NoaController.SetCustomToggle(1, true);

        // Get the toggle state of the custom action button #1 on the controller.
        bool customToggle = NoaController.GetCustomToggle(1);

        // Toggle the game state between paused and resumed.
        NoaController.TogglePauseResume();

        // Increase the game speed.
        NoaController.IncreaseGameSpeed();

        // Decrease the game speed.
        NoaController.DecreaseGameSpeed();

        // Set the game speed to its minimum value.
        NoaController.MinimizeGameSpeed();

        // Set the game speed to its maximum value.
        NoaController.MaximizeGameSpeed();

        // Stepping frame by frame.
        NoaController.FrameStepping();

        // Reset the game speed.
        NoaController.ResetGameSpeed();

        // Set the callback that will be invoked when the game state is toggled between paused and resumed.
        NoaController.OnTogglePauseResume = isPlaying => Debug.Log($"Game playing state has been changed: {isPlaying}");

        // Set the callback that will be invoked when the game speed is changed.
        NoaController.OnGameSpeedChanged = gameSpeed => Debug.Log($"Game speed has been changed: {gameSpeed}");

        // Set the callback for when stepping frames.
        NoaController.OnFrameStepping = () => Debug.Log("Frame stepping was executed.");

        // Get the game playing state.
        bool isGamePlaying = NoaController.IsGamePlaying;

        // Get the game speed set by the tool.
        float gameSpeed = NoaController.GameSpeed;

        // Transition to the application initial scene.
        NoaController.ResetApplication();

        // Set a callback to execute when the application reset occurs.
        NoaController.OnApplicationReset = () =>
        {
            Debug.Log("Application reset");

            // Return true to add a process to the application reset.
            // Return false to overwrite the application reset process.
            return true;
        };

        // Toggle the show state of the NOA Debugger-related UI.
        NoaController.ToggleNoaDebuggerUI();

        // Set a callback to execute when toggling the show state of the NOA Debugger-related UI.
        NoaController.OnToggleNoaDebuggerUI = isShow =>
        {
            Debug.Log($"Toggle the NOA Debugger UI: {isShow}");

            // Return true to toggle the show state, otherwise, false to cancel.
            return true;
        };

        // Set the callback that is fired before capturing a screenshot.
        // - The return value of the callback controls the contents of the screenshot. The return value should specify a combination of the flags.
        // - Return NoaController.ScreenshotTarget.All to include all NOA Debugger-related UI in a screenshot.
        NoaController.OnBeforeScreenshot = () =>
        {
            Debug.Log("Before capturing a screenshot.");

            return NoaController.ScreenshotTarget.LaunchButton | NoaController.ScreenshotTarget.UIElement;
        };

        // Set the callback that is fired when capturing a screenshot.
        NoaController.OnCaptureScreenshot = () =>
        {
            Debug.Log("Capturing a screenshot");

            // Returns true if you want to capture a screenshot,
            // or false if you do not want to perform the internal screenshot process.
            // (e.g., if you want to perform the screenshot process yourself).
            // If this callback returns false, NoaController.GetCapturedScreenshot() returns null.
            return true;
        };

        // Set the callback that is fired after capturing a screenshot.
        NoaController.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.
                NoaController.GetCapturedScreenshot();
            }
            else
            {
                Debug.LogError("No screenshot data.");
            }
        };

        // Capture a screenshot
        NoaController.CaptureScreenshot();
#endif
    }
}