We can also add 3D widgets directly within the environment, as shown:
In order achieve this, we must create an empty GameObject as a child of the Ground
GameObject, which has the UIPanel
component attached to it for widget rendering.
After this, we can create our widget, place it at the desired location, and make sure it lies in the default environment camera layer instead of the usual UI layer.
Let's try it now:
Select our
Ground
GameObject.Create a new empty child GameObject pressing Alt + Shift + N and select it:
Rename this new child to
LevelName
.Set its Transform position to {0, 0, -3.8}.
Click on the Add Component button in the inspector.
Type in
panel
to search for components with this name.Select NGUI Panel and hit Enter.
Create a new child sprite by pressing Alt + Shift + S.
Rename this new sprite to
Background
.Set Atlas to Wooden Atlas.
Change Sprite to the Flat sprite.
Make sure Type is set to Sliced.
Set Size to 360 x 100.
As you can see in the following screenshot...