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
  • NoaUIElement

NoaUIElement

NoaUIElement provides a convenient interface for dynamically registering and displaying various UI elements on the screen using the NOA Debugger. By using this class, developers can easily create, manage, and position UI elements.

Note: NoaUIElement is intended for use within the uGUI Canvas in Unity and is not supported for use in 3D space.

api-log

APIs

Static Methods

APIDescription
RegisterUIElement(element)Registers a new UI element.
UnregisterUIElement(key)Unregisters a UI element based on the specified key.
UnregisterAllUIElements()Unregisters all UI elements.
IsUIElementRegistered(key)Checks if a single UI element with the specified key is registered.
IsUIElementRegistered()Checks if any UI elements are registered.
SetUIElementVisibility(key, isVisible)Sets the visibility of a single UI element.
SetAllUIElementsVisibility(isVisible)Sets the visibility of all UI elements.
IsUIElementVisible(key)Checks if a single UI element with the specified key is visible.
IsUIElementVisible()Checks if all UI elements are visible.
SetVerticalAlignment(anchorType)Sets the anchor position alignment to vertical orientation.
Note: Vertical is the default orientation.
SetHorizontalAlignment(anchorType)Sets the anchor position alignment to horizontal orientation.

Sample Code

using System.Collections.Generic;
using UnityEngine;
#if NOA_DEBUGGER
using NoaDebugger;
#endif

public class Example
{
    void ExampleMethod()
    {
#if NOA_DEBUGGER

        // Register a text element (specified by anchor type)
        NoaUIElement.RegisterUIElement(
            NoaUITextElement.Create(
                key: "DebugText",                            // Unique key for the UI element
                value: () => $"Current Time: {Time.time}",   // Text content
                anchorType: AnchorType.UpperLeft,            // Anchor position
                updateInterval: 0.5f                         // Update interval (in seconds)
            )
        );

        // Register a button element (specified by parent object)
        NoaUIElement.RegisterUIElement(
            NoaUIButtonElement.Create(
                key: "ExampleButton",                        // Unique key for the UI element
                label: "Click Me",                           // Button label
                onClick: OnButtonClicked,                    // Callback for button click
                parent: parentTransform                      // Parent object's Transform
            )
        );

        // Register a custom object element (specified by anchor type)
        GameObject customPrefab = Resources.Load<GameObject>("CustomPrefab");
        NoaUIElement.RegisterUIElement(
            NoaUIObjectElement.Create(
                key: "CustomObject",                         // Unique key for the UI element
                prefab: customPrefab,                        // Custom prefab
                onObjectCreated: OnCustomObjectCreated,      // Callback for object creation
                anchorType: AnchorType.UpperCenter,          // Anchor position
                width: 200f,                                 // Width (in pixels)
                height: 100f                                 // Height (in pixels)
            )
        );

        // Unregister the UI element at any given time
        NoaUIElement.UnregisterUIElement("DebugText");

        // Unregister all UI elements
        NoaUIElement.UnregisterAllUIElements();

        // Check if a specific UI element is registered
        bool isTextRegistered = NoaUIElement.IsUIElementRegistered("DebugText");

        // Check if at least one UI element is registered
        bool hasRegisteredElements = NoaUIElement.IsUIElementRegistered();

        // Hide a single UI element
        NoaUIElement.SetUIElementVisibility("ExampleButton", false);

        // Show all UI elements
        NoaUIElement.SetAllUIElementsVisibility(true);

        // Check if a single UI element is visible
        bool isButtonVisible = NoaUIElement.IsUIElementVisible("ExampleButton");

        // Check if all UI elements are visible
        bool areAllVisible = NoaUIElement.IsUIElementVisible();

        // Sets the alignment to horizontal orientation
        NoaUIElement.SetHorizontalAlignment(AnchorType.UpperLeft);

#endif
    }

    // Callback when the button is clicked
    void OnButtonClicked()
    {
        Debug.Log("Button was clicked!");
    }

    // Callback when the custom object is created
    void OnCustomObjectCreated(GameObject obj)
    {
        Debug.Log("Custom object created: " + obj.name);
    }
}