Until now, we've created 2D user interface elements and flat widgets viewed with an orthographic camera, on which the z axis has no influence.
3D user interface elements are viewed with perspectives taken into account, which means that the z axis makes widgets feel "farther away" or "closer to" the camera. Rotation can also be applied, which will make them look like they are a part of the 3D environment.
In this section, we will create 3D user interface elements. First, we need to explain what the 3D UI Root is, and then create one.
It's interesting to separate our 2D and 3D layers in order to make sure you can easily hide or show one of them by simply enabling/disabling the camera that renders them.
Indeed, consider we have UI Root
to hold the 2D UI and another to hold the 3D UI exclusively. If we need to hide the 2D UI and show a 3D pause menu, we can simply perform the following steps:
Disable the 2D
UI Root
that holds and renders the in-game...