Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Unity Game Development Scripting
  • Table Of Contents Toc
Unity Game Development Scripting

Unity Game Development Scripting

By : D'Aoust
4.1 (7)
close
close
Unity Game Development Scripting

Unity Game Development Scripting

4.1 (7)
By: D'Aoust

Overview of this book

The intuitive and powerful Unity game engine is one of the most widely used and best loved packages for game development. Unity scripting is an essential but challenging skill to master in order to create custom game elements. Learning modular scripting allows you to rewrite as little code as possible as you deploy your scripts to multiple projects and work easier, quicker, and more efficiently than before. In each chapter of this book, you'll learn how to script new game elements. Beginning with making custom controls for the keyboard and mouse, as well as the Xbox 360 Controller, you'll then get to grips with more complex systems such as inventory, data saving, and artificial intelligence. As you create these elements, you'll also learn how to make your scripts simpler and easy to use. This will allow drag-and-drop deployment, which is to be used by designers and nonprogrammers. Finally, you'll combine all of your newfound skills to create your own complete game project.
Table of Contents (12 chapters)
close
close
11
Index

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 EmptyObject;
public int InventorySize = 9;
public GameObject[] invItems;
public GameObject[] QuickItems;

List<KeyValuePair<int, GameObject>> items = new List<KeyValuePair<int, GameObject>>();

List<KeyValuePair...
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Unity Game Development Scripting
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon