DEV Community

Discussion on: Gaming JavaScript

Collapse
 
ky1e_s profile image
Kyle Stephens

Unity Game Engine also supports a JavaScript syntax.

Collapse
 
kayis profile image
K

Nice!
Could you elaborate? :D

Collapse
 
homerdalords profile image
Omar

A lot of people like to call UnityScript by the name "JavaScript." I believe this is wrong on several levels.

While "JavaScript" could refer to any one of the ECMAScript specs, Unity's ".js" language doesn't even come close to conforming to that specification — nor does it try to. UnityScript is a proprietary language, and it doesn't follow any concrete specification; it is modified at the will of the Unity developers.
The vast majority of JavaScript libraries you find will not work just by copying them into Unity. Unity's "JavaScript" is most similar to Microsoft's JScript.NET, although it is not quite identical.

  • JS is class-free, UnityScript have them, and that once defined are fixed for the duration of the runtime.
  • File name matters in UnityScript, where most files represent a single class.
  • UnityScript supports .NET OOP features like classes,"protection levels" (public, private, protected) and "static" keyword options. Since it also supports explicit typing, it also has support for "generics" (runtime type enforcement), which JavaScript has no notion of.
  • And unlike the popularity of Javascript, UnityScript should be buried deep and nobody should be allowed to use it, at all.
Collapse
 
ky1e_s profile image
Kyle Stephens

It's a JavaScript-like syntax, as opposed to JavaScript run on a JavaScript engine. A familiarity with JS means that you can pick up their script very quickly by referencing their API docs.

It should be noted that Unity is a proprietary engine and the specifications can change at the whim of Unity. The positives are that it comes with a Rich IDE/modelling tool where you can create objects and environments.

As noted by Michael, it's being deprecated this year so maybe best to avoid. :(

Collapse
 
michaeljota profile image
Michael De Abreu

Actually UnityScript, Unity flavor of Javascript that have types, is deprecated, and will be removed this year from the Engine. Unfortunately.

Collapse
 
ky1e_s profile image
Kyle Stephens

:(