- Defining classes and variables
- Attaching scripts to objects
- Understanding MonoBehaviour class
- Using the Unity Scripting API
- Importing assets
- Using a singleton pattern to manage game state
- Creating an event
Skill Level Intermediate
- Hi, I'm Kelley Hecker, and welcome to Scripting Unity with C#. Unity has many built in systems that allow you to create and customize your game. However, scripting is Unity's most powerful tool, giving you the ability to customize objects and control how they behave in the game. In this course, I'll show you how to create and attach C# scripts to game objects in Unity and introduce you to the development environment, MonoDevelop. Most of the scripts that you write in Unity will be extensions of the MonoBehaviour class, so we'll take an in-depth look at how the MonoBehaviour class functions.
We'll also look at some of the other built-in Unity classes you'll likely use while creating games. Finally, I'll cover the singleton pattern and events, which are two techniques that are especially useful for managing your game state, and allowing game objects to communicate with each other. So, if you're ready, let's get rolling!
Q: Why am I getting a script compile error when trying to load the exercise files?
A: This course was recorded in <span class="il">Unity</span> 4.6, and <span class="il">Unity</span> has since released <span class="il">Unity</span> 5. There are two items to address for <span class="il">Unity</span> 5 users. <div></div><div>First, you'll need to update the scripts when <span class="il">Unity</span> prompts you to. Alternatively, you can load projects from the <span class="il">Unity</span> 5 folder inside of the exercise files.</div><div></div><div>Second, when you import the Sample Assets (beta) for <span class="il">Unity</span> 4.6 from the <span class="il">Unity</span> Store, deselect or delete the WaterHoseParticles.cs file from the SampleAssets/Effects/<wbr>ParticleSystems/scripts folder. This script is currently incompatible with <span class="il">Unity</span> 5.</div>
Q: Why can't I see the Render Settings option in the Edit menu?
A: The Render Settings options have been moved in Unity 5. You can access them by going to the Window menu and choosing Lighting. In the window that loads, Render Settings can be found under the Scene tab.