To expand on the answers already given:
In both Unity and your web browser (assuming your browser uses Gecko (e.g. Firefox) or WebKit (e.g. Chrome)) you can program things using JavaScript (Trident (e.g. Internet Explorer) for example implements JScript instead, but see the next sentence).
Actually, Unity does not implement JavaScript, but an ECMAScript dialect (one of which is also JavaScript).
That does not mean that you can easily execute code written for the one with the other.
While the language itself stays the same (assuming you use the same dialect or restrict yourself to the common elements), the execution environment changes.
What that means is that for example this:
Code: Select all
function f(x) {
return x + 40;
}
y = f(2);
will work fine in both Unity and your browser, because here we only use the language, but this
will only work in your browser (unless Unity has/adds it own alert-function).
The alert-function is not part of JavaScript itself, but is provided by the browser as an environment so you can interact with it.
Likewise, Unity will provide things to interact with the game engine.
Some libraries providing additional functionality could be used in both of them, perhaps something like Box2D, if it is written purely in a compatible dialect without using any 'external functionality'.
And you can theoretically implement a JavaScript engine anywhere. You could use it as the default shell of an operating system if you wished to do so. You can write web servers in Javascript, see node.js.
Unity also allows use of other languages, like C# and a Python-dialect called Boo.
APsychonaut wrote:Razor wrote:
Think of Garry's Mod: You can script stuff for it in Lua, but the core game surely wasn't written in Lua.
off topic: Source is either in C or C++
Source is written in C++, though some code fragments look like C and there are a few lines inline assembler.
The build-system also used to have some Perl, not sure if it's still there.
And Shaders are written in HLSL, though maybe they switched to GLSL or something for OS X and Linux, or perhaps they use a HLSL->GLSL translation tool.
And you could argue that they've implemented a programming language for use in mapping, that is their I/O system. I have no reference to back this claim, but my guess is that it's even turing complete with the entities provided by default. It's a stretch to call that a programming language anyways.