Programming Introduction Old

From Unify Community Wiki
Jump to: navigation, search

Author: Lucas Goss



This book is a beginners guide to programming using Unity. It will be concise and cover most of the basics of programming while hopefully giving you enough of an understanding to be able to figure out and use other documentation (such as the Unity Docs). The examples will use JavaScript and C# in order to teach language concepts instead of just a language syntax. I hope you enjoy it.

Languages & Compilers

The languages used by Unity are all .NET based languages on Mono. A .NET based language for Mono is one that can be compiled to pure IL (Intermediate Language). The languages currently supported by Unity are JavaScript, C#, and Boo.

Now if I lost you at compiled and IL... hold on. A compiler is a program that takes code and converts it into machine code (less human readable). IL is just a generic language that is platform independent, but harder to read and manage by coders. When a .NET program is run (executed), the generic language then gets translated to machine native code. This is pretty much the same as Java. Java and .NET are just platform independent platforms.


A quick word about JavaScript. JavaScript is also known as ECMAScript (About Javascript (Wikipedia) ). The JavaScript in Unity is a custom implementation, implemented for Unity Technologies by Rodrigo Barreto de Oliveira, the creator of Boo and uses much code from the Boo implementation. It is essentially most of ECMAScript Edition 4 (JavaScript 2.0) with a few omissions. JavaScript 2.0 is the new proposed JavaScript, but is not yet finalized, so it is not yet a standard. Most implementations that currently exist for the browser are JavaScript 1.x (ECMAScript 3).

The custom implementation in Unity has the following differences from JavaScript 2.0 (just for reference):

  • NO expando objects
  • NOT ALL built in types exist (a few missing)
  • NO automatic semicolon insertion
  • CANNOT change variable type
  • #pragma strict forces static typing
  • Implicitly defines a class that inherits MonoBehavior


Here are some useful references that will help you along the way as a supplement to the material here, so you may want to bookmark them for future use.


JavaScript 2.0
JavaScript Types
JavaScript on Mozilla


Boo Primer
Boo Language Guide


Mono C# Compiler
C# Keywords
C# Operators
C# Types Reference

.NET (all languages)

Mono Documentation
Microsoft Documentation

Programming Index : Next Chapter

Personal tools