NoaDebug
Through this class, you can control the initialization and launch of NOA Debugger from the script.
APIs
Static Methods
API | Description |
---|---|
Initialize() | Initializes the tool. |
Show() | Launches the tool and opens a last displayed menu. |
Show(index, isCustomMenu) | Launches the tool and opens a specified menu. If isCustomMenu is true, it opens the custom menu. |
Show(menuType) | Launches the tool and opens a specified menu. Custom menus are not supported. |
Hide() | Closes the tool and display the enabled overlay/floating window. |
SetDebuggerActive(isActive) | Toggles the display/hide of the tool. |
SetOverlayActive(isActive) | Toggles the display/hide of the tool's overlay. |
SetOverlayEnabled(feature, isEnabled) | Toggles the enable/disable of the specified feature. |
GetOverlayEnabled(feature) | Gets whether the specified overlay feature is enabled. |
SetFloatingWindowActive(isActive) | Toggles the display/hide of the tool's floating window. |
SetTriggerButtonActive(isActive) | Toggles the display/hide of the tool's launch button. |
SetFont(fontAsset, fontMaterial, fontSizeRate) | Configure the fonts used for the tool. If fontMaterial is omitted, the default material of the specified font asset will be applied. If fontSizeRate is omitted, it will be treated as a 1:1 size. |
Instantiate(prefab, group) | Generates objects at the same hierarchy level as the tool's UI. The hierarchy levels that can be specified are as follows: - NoaDebug.HierarchyLevelGroup.FloatingWindow: The hierarchy for the floating window - NoaDebug.HierarchyLevelGroup.UIElement: The hierarchy for the NoaUIElement - NoaDebug.HierarchyLevelGroup.MainView: The hierarchy for the main view - NoaDebug.HierarchyLevelGroup.Dialog: The hierarchy for dialogs - NoaDebug.HierarchyLevelGroup.Overlay: The hierarchy for overlays |
SetShortcutsEnabled(isEnabled) | Set shortcuts enabled. |
EnableWorldSpaceRendering(worldCamera) | Displays the tool on the world coordinates. If the arguments are omitted, the MainCamera is applied to the Canvas drawing. While displayed on the world coordinates, the overlay, the floating window and the launch button are not displayed. |
DisableWorldSpaceRendering() | Displays the tool on 2D screen coordinates. |
CopyToClipboard(text) | Copies the specified text to the clipboard. The size that can be copied depends on the platform, device specifications, and memory usage. If the copy fails due to exceeding the size limit, the following behaviors have been observed: - An error log is output - The application crashes - The application becomes unresponsive due to insufficient memory Note: For web platforms, this will not work unless permission is granted in advance or it is triggered by a user action such as pressing a button. |
DownloadText(text, fileName, mimeType) | Downloads the specified text as a file with the specified name. The mimeType is used for displaying the download dialog on Android and web platforms. For how to specify it, please refer to this document. For the storage location of the downloaded file, please refer to About Download. |
Destroy() | Destroys the tool. |
Static Properties
API | Description |
---|---|
OnShow | Callback that is fired when the tool is launched. You can get the index value of the menu when the callback is fired. |
OnHide | Callback that is fired when the tool is closed. You can get the index value of the menu when the callback is fired. |
OnMenuChanged | Callback that is fired when the tool menu is switched. You can get the index value of the menu after the switch and a flag indicating whether it is a custom menu when the callback is fired. |
RootTransform | Returns a reference to the most top-level Transform of the tool. |
IsInitialized | Returns true if the tool is initialized. |
IsShortcutsEnabled | Returns true if shortcuts are enabled. |
IsWorldSpaceRenderingEnabled | Returns true if the tool is being displayed on the world coordinates. |
IsDebuggerVisible | Returns true if the tool is displayed. |
IsTriggerButtonVisible | Returns true if the tool's launch button is displayed. |
IsOverlayVisible | Returns true if the overlay is displayed. |
IsFloatingWindowVisible | Returns true if the floating window is displayed. |
Sample Code
using System.Text;
using UnityEngine;
#if NOA_DEBUGGER
using NoaDebugger;
#endif
public class Example
{
void ExampleMethod()
{
#if NOA_DEBUGGER
// Initialize the tool.
NoaDebug.Initialize();
// Check if the tool has been initialized.
bool isDebuggerInit = NoaDebug.IsInitialized;
// Set a callback to execute when the tool is launched.
NoaDebug.OnShow = (index) => Debug.Log($"showIndex:{index}");
// Open the last displayed menu of the tool.
NoaDebug.Show();
// Set a callback to execute when the tool is closed.
NoaDebug.OnHide = (index) => Debug.Log($"hideIndex:{index}");
// Close the tool.
NoaDebug.Hide();
// Open the specified index of the tool.
NoaDebug.Show(3);
// Open the specified menu.
NoaDebug.Show(NoaDebug.MenuType.Profiler);
// Set a callback to execute when the tool menu is switched.
NoaDebug.OnMenuChanged = (index, isCustomMenu) => Debug.Log($"menuIndex:{index} isCustomMenu:{isCustomMenu}");
// Hide the tool.
NoaDebug.SetDebuggerActive(false);
// Show the tool.
NoaDebug.SetDebuggerActive(true);
// Hide the tool's overlay.
NoaDebug.SetOverlayActive(false);
// Show the tool's overlay.
NoaDebug.SetOverlayActive(true);
// Gets profiler overlay enabled.
bool isProfilerEnabled = NoaDebug.GetOverlayEnabled(NoaDebug.OverlayFeatures.Profiler);
// Disable the profiler overlay.
NoaDebug.SetOverlayEnabled(NoaDebug.OverlayFeatures.Profiler, false);
// Enable the profiler overlay.
NoaDebug.SetOverlayEnabled(NoaDebug.OverlayFeatures.Profiler, true);
// Hide the tool's floating window.
NoaDebug.SetFloatingWindowActive(false);
// Show the tool's floating window.
NoaDebug.SetFloatingWindowActive(true);
// Hide the tool's launch button.
NoaDebug.SetTriggerButtonActive(false);
// Show the tool's launch button.
NoaDebug.SetTriggerButtonActive(true);
// Set the tool's font.
var assetBundle = AssetBundle.LoadFromFile($"{Application.streamingAssetsPath}/ExampleFont");
var fontAsset = assetBundle.LoadAsset<TMP_FontAsset>("Assets/AssetBundleResources/ExampleFont.asset");
NoaDebug.SetFont(fontAsset, fontAsset.material, 1.0f);
// Generate custom objects in the tool's hierarchy level.
var obj = Resources.Load<GameObject>("Prefabs/ExamplePrefab");
NoaDebug.Instantiate(obj, NoaDebug.HierarchyLevelGroup.Dialog);
// Enable shortcuts.
NoaDebug.SetShortcutsEnabled(false);
// Disble shortcuts.
NoaDebug.SetShortcutsEnabled(true);
// Check if shortcuts is enabled.
bool isShortcutsEnabled = NoaDebug.IsShortcutsEnabled;
// Display the tool on the world coordinates.
NoaDebug.EnableWorldSpaceRendering(Camera.main);
// Get a reference to the most top-level Transform of the tool.
Transform noaDebuggerRoot = NoaDebug.RootTransform;
// Change the tool's coordinates, rotation angle, and scale.
// - This is only applied when displayed on world coordinates.
// - Please control the size change with scale.
// - Since the canvas size of NOA Debugger is 1136x640, it will be approximately 3x1.7m in the following example.
noaDebuggerRoot.localPosition = Vector3.zero;
noaDebuggerRoot.localEulerAngles = Vector3.zero;
noaDebuggerRoot.localScale = new Vector3(0.00264f, 0.00264f, 0.00264f);
// Change the tool's layer.
noaDebuggerRoot.gameObject.layer = 0;
// Whether the tool is displayed on world coordinates.
bool isWorldSpace = NoaDebug.IsWorldSpaceRenderingEnabled;
// Display the tool on 2D screen coordinates.
NoaDebug.DisableWorldSpaceRendering();
// Copy the specified text to the clipboard.
NoaDebug.CopyToClipboard("sample text to clipboard");
// Download the specified text as plain text.
NoaDebug.DownloadText("sample text", "sample.txt", "text/plain");
string[][] sampleData =
{
new [] { "No", "Name", "Value" },
new [] { "1", "sample1", "100" },
new [] { "2", "sample2", "1000" },
new [] { "3", "sample3", "500" }
};
// Download the specified text as a JSON file.
string sampleJson = JsonUtility.ToJson(sampleData);
NoaDebug.DownloadText(sampleJson, "sample.json", "application/json");
// Download the specified text as a CSV file.
StringBuilder stringBuilder = new StringBuilder();
foreach (string[] row in sampleData)
{
stringBuilder.AppendJoin(",", row);
stringBuilder.AppendLine();
}
string sampleCsv = stringBuilder.ToString();
NoaDebug.DownloadText(sampleCsv, "sample.csv", "text/csv");
// Check if the tool is displayed.
bool isDebuggerVisible = NoaDebug.IsDebuggerVisible;
// Check if the tool's launch button is displayed.
bool isTriggerButtonVisible = NoaDebug.IsTriggerButtonVisible;
// Check if the overlay is displayed.
bool isOverlayVisible = NoaDebug.IsOverlayVisible;
// Check if the floating window is displayed.
bool isFloatingWindowVisible = NoaDebug.IsFloatingWindowVisible;
// Execute the disposal of the tool.
NoaDebug.Destroy();
#endif
}
}