Book Image

Unity Game Development Scripting

By : D'Aoust
Book Image

Unity Game Development Scripting

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)
11
Index

Making video configurations


One of the first aspects of the game that we will be editing is the video configuration. When it comes to performance, the video settings are perhaps the most important. Changing something as simple as the shadows can greatly change how a player can smoothly play the game. So let's get started by creating a new C# script and naming it Video_Config.

Setting the values

Our first step in creating video configurations is to create a function that will set a default value for the video settings. For this, we will set the video settings to moderate values that aren't too low or too high. This will give the player a good idea of what they need to modify if they need or want to modify anything:

public void SetDefaults()
{
  SetSettings("Medium");
  ToggleShadows(1);
  SetFOV(90.00f);
  SetResolution(0, 1);
  SetAA(2);
  SetVsync(1);
}

What this function does is call all of the functions that we create, which will configure the video settings. The values that we send to each...