- The default development environment…for writing scripts in Unity is MonoDevelop,…which comes installed with Unity.…You can also set up VisualStudio to work with Unity.…But out of the box, MonoDevelop is the easiest to use.…I'll be showing you how to create…a script in the next chapter.…But for now I've just created a new script…and I'm going to double click to open it in MonoDevelop.…One of the great things about Unity is that your…scripts will compile automatically when you change them.…

If I add a new bit of code,…save and go back to the Editor,…I know my script is compiling…because of the spinning icon in the bottom…right corner of the Editor.…Because of this you probably won't use MonoDevelop…for much more than text editing.…But you can use it for debugging…by going to Run, Attach to Process,…selecting the Unity Editor,…and clicking Attach.…You can set break points by clicking in…the margin to the left of the line numbers.…

This red dot is a breakpoint.…It allows you to pause your application…when a specific line of code is reached.…

Resume Transcript Auto-Scroll

Author

Released

3/24/2015

Unity games can be scripted in several languages, but the most popular and powerful choice is C#. In this course, game development engineer Kelley Hecker walks through the process of creating and attaching C# scripts to your game objects in order to customize their appearance and control their behavior. The course includes an in-depth exploration of the MonoDevelop scripting environment; MonoBehaviour, the base class for almost every script; and Unity's built-in classes, which prime your scripts for success. Plus, get an introduction to using the singleton pattern to manage game states and using events to respond to user input (for example, to deal damage when a player makes a mistake).

Topics include:

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

1h 19m

Duration

194,651

Views

Show MoreShow Less

Q: Why am I getting a script compile error when trying to load the exercise files?

A: This course was recorded in Unity 4.6, and Unity has since released Unity 5. There are two items to address for Unity 5 users.

First, you'll need to update the scripts when Unity prompts you to. Alternatively, you can load projects from the Unity 5 folder inside of the exercise files.

Second, when you import the Sample Assets (beta) for Unity 4.6 from the Unity Store, deselect or delete the WaterHoseParticles.cs file from the SampleAssets/Effects/ParticleSystems/scripts folder. This script is currently incompatible with Unity 5.

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.