Click here to Skip to main content
12,695,694 members (29,342 online)
Click here to Skip to main content
Add your own
alternative version


16 bookmarked

Unity and C#: Learn Scripting

, 7 Apr 2014 CPOL
Rate this:
Please Sign up or sign in to vote.
Unity and C#: Learn scripting

Scripting is an essential ingredient in all games. Even the simplest game will need scripts to respond to input from the player and arrange for events in the gameplay to happen when they should.


Everything in unity3D is a GameObject. We first start building a game by setting the sprites (2D) / 3D models in their respective positions. In a 2D game setup, Players and enemies will be in the foreground and other elements which we don’t interact much will be in the background. Once this is done, you have some non-moving static GameObjects. It's just like a photo rather than a video which you enjoy watching.

To make these Gameobjects move, to be more precise, move according to your inputs/instructions. Scripting is very much required.


Unity supports three programming languages natively:

  • C# (pronounced C-sharp), an industry-standard language similar to Java or C++
  • UnityScript, a language designed specifically for use with Unity and modelled after JavaScript
  • Boo, a .NET language with similar syntax to Python

Which One Should I Learn and Use ?

Huff!! A very tough question to answer. There’s always a missing clarity on this. To be diplomatic, I can answer like this:

Every Language has its own pros and cons.

But I won’t…. I support C# because:

  • It's a strongly-typed, type-safe language
  • Purely based on Object-Oriented programming concepts
  • Above all, I am comfortable with C# as my background is .NET

Note: Boo, as of now, is completely out of the race.

Whenever I have this question, I read this:

I would say it depends very much on your past experience. If your background is in C++ or Java, you will likely feel most at home in C# – however if you’re experienced with dynamically typed languages such as JavaScript / Basic or PHP, chances are you will prefer JavaScript.

If you have no previous experience with programming – JavaScript might be an easier introduction – given that you do not need to worry about types and casting.

Do note that writing JavaScript in Unity is not the same as writing it for web browsers (which is why it is popularly nicknamed UnityScript in the community). You should check out the tutorials to familiarize yourself with it if this is the route you’re going to take.

If you are planning to work with other programmers on a Unity project, I very much recommend that you decide from the beginning to work in the same language. While it is completely possible to combine scripts written in multiple languages into one project, you will very likely at some point run into issues due to the nature of the task of compiling and linking multiple languages.

Finally, do notice that all documentation and tutorials for Unity are currently written in JavaScript and of the three available languages for Unity, only C# examples are given in the .NET documentation (since you are working with mono, you have full access to the mono port of the .NET library).

Learning scripting is not a one day task. Scripting is a skill that takes some time and effort to learn.

Here are some links to start with:

Video Tutorials

Courtesy: Unity3D docs and Forums

Filed under: C#, unity
Tagged: C# scripting unity3d, learn, learn unity scripting, learn unity2d, programming languages, Scripting, Unity and C# : Learn Scripting, Unity project


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Vidyasagar Machupalli
Software Developer (Senior)
India India
Developer | Blogger | Mentor | Gamer | Microsoft MVP
Coder by profession | Gamer By Heart
Technical Blog :
About me:

You may also be interested in...

Comments and Discussions

-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170118.1 | Last Updated 8 Apr 2014
Article Copyright 2014 by Vidyasagar Machupalli
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid