Hi folks,
maybe some of you have seen the Tank tutorial, where they turn the canvas beneath a tank, as a healthbar. Is this possible with the new UI system (yet?).
Thanks,
Slarti
Hi folks,
maybe some of you have seen the Tank tutorial, where they turn the canvas beneath a tank, as a healthbar. Is this possible with the new UI system (yet?).
Thanks,
Slarti
As a workaround for having this natively supported by the UI Document component, you can use a combination of UI Document with a custom Panel Settings asset that has a Target Texture, and then render that target texture on a world-space canvas with RawImage:
You’ll also need to tick the first checkbox under the Clear Settings section of the Panel Settings asset:
For some reason mine doesn’t have a label, but hovering over it shows that it will clear the color buffer before rendering.
This will prevent the UI being rendered on top of the previous Render Texture contents.
With all of that done, you should end up with something like this, and any updates to the UI Document will be updated in the render texture:
Why are shadows not displaying on top of the UI?
I’m using the default UI material for the RawImage component which is unlit, which is why shadows aren’t displaying over the texture. If you want shadows to affect the texture, you’ll have to get a lit material working.
Why are my changes not refreshing in the scene view?
This may be a side-effect of the way render textures are handled, as it seems like the render texture is only redrawn when the Game view is visible.
To get the texture to refresh in the scene view, you’ll need to either switch to the Game view and back, or have the game view visible as a docked panel.
This will also affect play mode, and the same fix will apply.