Unity UI Toggle Button Not Working in Sandbox Scene with Needle.JS

The same Toggle button setup works as expected in scenes without Needle.JS.
Is the Unity Toggle button supported in Needle.JS, or is there additional setup required for compatibility?

Steps to Reproduce: Add a Toggle button in a Needle.JS-enabled scene, assign an event listener, and observe its non-functionality.

Hi Parul Bhatti,

It seems the Unity UI Toggle button may require additional setup to work correctly in a Needle.JS-enabled scene. The common issues with UI elements in Needle Engine are often related to how event handling is configured, especially in scenes where Needle Engine manages rendering and event systems differently compared to standard Unity scenes.

Steps to Check and Implement:

  1. Event Handling: Ensure that the EventSystem component is present in your scene. Without it, UI elements like the Toggle won’t receive events.

  2. Raycasting: Verify that the objects involved have appropriate colliders and are set up correctly for raycasting. The toggle needs to be interactable and there must be a raycaster set up on the UI system.

  3. Ensure Clickable: Use the SetActiveOnClick component for basic interactivity, ensuring that each clickable element in your UI is properly configured. The following function will help ensure your UI element can be clicked:

    private void Start()
    {
        SetActiveOnClick.EnsureIsClickable(gameObject);
    }
    
  4. Debug: Use debug logs to confirm that event listeners are firing correctly. You can attach a listener to the Toggle to output a message when the value changes:

    Toggle toggle = GetComponent<Toggle>();
    toggle.onValueChanged.AddListener((value) => { Debug.Log("Toggle is now: " + value); });
    
  5. Check Compatibility: If the above troubleshooting steps don’t resolve the issue, consider checking the Needle Engine documentation for any updates regarding support for Unity UI elements, as compatibility can evolve with new releases.

If these steps don’t address the problem, more specific details about versions and configurations can help narrow down the compatibility or setup issues further.

Refer to the Needle Engine documentation for more details on UI support: Needle Engine Documentation.

Feel free to provide additional details about your setup so I can assist further!

1 replies left - Get a PRO license for more AI replies.
thread_1bn957zqrDJZ7ICLnfWjF3vh
Reply to this message to continue the conversation

1 Like

Hi,

the Toggle UI component is not supported by Needle Engine at the moment.

You can find a list of UI components in the docs that we currently export: Needle Core Components | Needle Engine Documentation or check with the API docs: Built-in Components | Needle Engine

Generally you should see a blue link label mentioning needle engine at the top of the component (e.g. when you select a MeshRenderer for example) which indicates that the component is exported to the web.

Hope this helps.

This topic was automatically closed 13 days after the last reply. New replies are no longer allowed.