Summary

In this chapter, you learned how to create in-game 2D user interfaces and how to implement them in a simple game example. We made sure our power sources were draggable in the 3D space using the UIDragObject component by the use of its Movement vector parameter to limit the movement to a horizontal plane.

We used NGUI's OnPress() event on 3D world elements to add character movement when the player clicks on the ground or any other interactive element.

We have created the elemental switch UI for the player to switch the power source's current element using the four Fire, Ice, Lightning, and Water buttons. The current element's button is grayed out using the isEnabled Boolean.

Using the new FollowObject component we created, we can now force a 2D UI widget to follow any object within the 3D scene with a configurable Offset vector. It was used to make sure the elemental switch UI remains displayed over the concerned power source.

A progress bar has been added to the power sources in order to give the player feedback on the elemental switch duration.

Finally, we made sure we could launch our game from the main menu by adding a fade-out effect of the main menu's background texture.

Now that we've seen how to integrate in-game 2D user interfaces within the 3D environment, let's see how we can add 3D user interface elements in Chapter 7, 3D User Interface.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.231.194