O'Reilly logo

Unity 3 Game Development HOTSHOT by Jate Wittayabundit

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Variable declaration

Variable declaration is different, including access and type specification.

JavaScript: The type specification is not necessary.

public var playerLife = 1;       // a public var
int playerLife = 2;        // **private** access is default
public GameObject myObj;      // a type is specified (no value assigned)

C#: The type is always stated when declaring a variable.

var playerLife = 1;         // **public** access is default
private var playerLife = 2;      // a private var
var myObj : GameObject;       // a type is specified (no value assigned)

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required