Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Is it possible to interact with a UI Document in World Space from VR? (No canvas)

Discussion in 'XR Interaction Toolkit and Input' started by ktdab, Jul 28, 2022.

  1. ktdab

    ktdab

    Joined:
    Sep 22, 2018
    Posts:
    6
    Hi, thanks for reading!

    The new UI system is great for building a UI quickly, but rendering the document in world space seems a bit clunky.

    To draw it I first created a Quad,
    Added a UI Document component,
    Created a new Texture
    Created a new Panel Settings with "Target Texture" set to the new Texture
    Applied the Texture/Material to the Quad

    The document is drawn correctly on the Quad, but is it possible to interact with the buttons/UI elements?

    Traditionally a ray could be casted from the controller to the world space UI objects, but in this case there is only 1 GameObject (the quad). Perhaps it would be possible to trace the point of collision on the quad to some hard-coded mapping of where the button boundaries are, but this would require adjustment every time a modification is made to the UXML document.

    Is there a way to simulate a click on the UIDocument maybe?

    Thanks again for reading, any comments are appreciated.
     
  2. ktdab

    ktdab

    Joined:
    Sep 22, 2018
    Posts:
    6
    [1 - month update]

    To anyone who might find this in the future - I highly recommend NOT using Unity's new UI toolkit with XR. Stick with the old canvas/UI approach where each element is a GameObject and add a TrackedDeviceGraphicRaycaster component from the Unity XR Toolkit to your root canvas GO.

    If there comes a time when the new UI Toolkit uxml can build into the old Unity.UI objects then it might still be useful for designing UI's, but so far the new UI Toolkit needs some serious workarounds for worldspace, and then another layer of workarounds for XR.

    If you are still determined to use the UI Toolkit in worldspace and XR, this is a good starting point: https://github.com/katas94/WorldSpace_UIToolkit_XR (disclaimer: not my github)
     
  3. unity_28A17AB9164083D89879

    unity_28A17AB9164083D89879

    Joined:
    Dec 22, 2022
    Posts:
    1
    Thanks for the update