O'Reilly logo

Unity Game Development Scripting by Kyle D'Aoust

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating the inventory script

For our inventory, we'll only use one script, so let's get it started.

Creating and naming the script

The first thing we need to do is to create a new C# script and name it Inventory. When you open the script, delete the Start and Update functions, leaving an empty class for us to use.

Adding the necessary variables

First, add this using statement where the other using statements are. The using statement will be needed so that we can use the List container variable:

using System.Collections.Generic;

Now, let's add the variables we require and place them after the opening class defining bracket:

bool showInventory = false; public Rect inventoryRect = new Rect(Screen.width / 2, Screen.height / 2, 400, 400); public GameObject ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required