CHAPTER 14

image

Managing the Inventory

Having taken care of most of the preliminary setup for your inventory system, in this chapter, you will be adding the code that handles its onscreen presentation and layout. Because an array of all the objects currently in inventory is key to the task, you will be adding most of the inventory-related code to the GameManager script, so it can be easily accessed.

Organizing the Inventory Objects

To start, let’s add an internal array to hold the objects. Because it will be constantly growing and shrinking, it would be nice to be able to use a JavaScript type array. But because JavaScript arrays are dynamically typed, ...

Get Beginning 3D Game Development with Unity 4: All-in-One, Multi-Platform Game Development, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.