NoaController
Through this class, you can control the various operations on the controller from the script.
APIs
Static Methods
| API | Description |
|---|---|
| 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. |
| SetApplicationResetCallbacks(callbacks) | Configure application reset–related events by creating a custom class and passing it as an argument. For detailed information about the argument, please refer to NoaApplicationResetCallbacks. |
| SetToggleUICallbacks(callbacks) | Configure events related to toggling the visibility of the NOA Debugger UI by creating a custom class and passing it as an argument. For detailed information about the argument, please refer to NoaToggleUICallbacks. |
| SetScreenshotCallbacks(callbacks) | Configure screenshot-related events by creating a custom class and passing it as an argument. For detailed information about the argument, please refer to NoaScreenshotCallbacks. |
Static Properties
| API | Description |
|---|---|
| OnShow | Callback that is fired when the controller is displayed. |
| OnHide | Callback that is fired when the controller is closed. |
| OnTogglePauseResume | Callback 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. |
| OnGameSpeedChanged | Callback that is fired when the game speed is changed. You can get the changed game speed when the callback is fired. |
| OnFrameStepping | Callback that is fired when stepping frames with the tool. |
| IsVisible | Returns true if the controller is displayed. |
| IsGamePlaying | Returns true if the game is playing, false if game is paused. |
| GameSpeed | Returns 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;
// Set the events to execute at application reset using a custom-defined class.
var applicationResetter = new ExampleApplicationResetter();
NoaController.SetApplicationResetCallbacks(applicationResetter);
// Transition to the application initial scene.
NoaController.ResetApplication();
// Set the events to execute when toggling NOA Debugger UI visibility using a custom-defined class.
var noaDebuggerUIVisibilityManager = new ExampleNoaDebuggerUIVisibilityManager();
NoaController.SetToggleUICallbacks(noaDebuggerUIVisibilityManager);
// Toggle the show state of the NOA Debugger-related UI.
NoaController.ToggleNoaDebuggerUI();
// Set the events to execute when capturing screenshots using a custom-defined class.
var screenshotManager = new ExampleScreenshotManager();
NoaController.SetScreenshotCallbacks(screenshotManager);
// Capture a screenshot
NoaController.CaptureScreenshot();
#endif
}
}
