Search Unity

UI Toolkit World Space?

Discussion in 'UI Toolkit' started by robinspots, Jun 8, 2020.

  1. robinspots

    robinspots

    Joined:
    May 10, 2018
    Posts:
    13
    I'm loving the UI Builder and USS system!

    I'm hoping that it's possible to render a UI in world space. There seems to be a 'target texture'
    RenderTexture for that exact purpose but whenever I attach a render texture to my Panel Renderer I get the following error:

    NullReferenceException
    UnityEditor.SceneView.OnGUI () (at <cf7d2c2e83f749e8943578126f9eff4b>:0)
    System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <437ba245d8404784b9fbab9b439ac908>:0)

    etc...

    Does anyone know of a workaround?
     
  2. mcoted3d

    mcoted3d

    Unity Technologies

    Joined:
    Feb 3, 2016
    Posts:
    1,003
    I'm unable to reproduce this issue using the "CPH2019RuntimeDemo" project. Do you have a simple example that reproduces the issue?
     
  3. mbeh4678

    mbeh4678

    Joined:
    Aug 30, 2019
    Posts:
    1
    Do you have any update on this? This is exactly the problem I am dealing with.
     
  4. mcoted3d

    mcoted3d

    Unity Technologies

    Joined:
    Feb 3, 2016
    Posts:
    1,003
    No update, never reproduced this issue. Feel free to file a new bug (Help > Report a Bug...) on a project that reproduces the issue.
     
  5. felipemullen

    felipemullen

    Joined:
    Mar 4, 2017
    Posts:
    44
    Depending on your implementation needs (supposing you don't need world lighting/shading) you can just have an overlay UI and modify the coordinates of your overlay.

    For example, if you need a health bar displayed above a character, you would translate the 3d coordinates of the transform into 2d space to get the screen position as seen by the camera, and get the appearance of world space
     
  6. felipemullen

    felipemullen

    Joined:
    Mar 4, 2017
    Posts:
    44