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 : Kyle D'Aoust
4.1 (7)
close
close
Unity Game Development Scripting

Unity Game Development Scripting

4.1 (7)
By: Kyle 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

Displaying the achievements on screen


Just as we did with the stats, we will have a new menu for achievements. First, we'll start by adding a couple of variables:

public bool showAchievements = false;
public Rect achRect = new Rect(Screen.width / 2, Screen.height / 2, 700, 700);

Adding the GUI functions

Now, we will add the functions to show the achievements on the screen. The first function is the OnGUI function, which we will add now:

void OnGUI()
{
  if(showAchievements)
  {
    achRect = GUI.Window(0, achRect, AchGUI, "Achievements");
  }
}

Just as in the stats menu, we check whether we want to show the achievements menu. If we do it, is shown on screen; if not, we hide it.

Next, we will add the AchGUI function that is being called in the OnGUI function. This is a large function, but it will allow us to show the achievements that we need. It is similar to the stat menu, except we will show buttons instead of a number. We use buttons just as a proof of concept; normally, you would use an image...

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