82

What language does one need to use when programming with Unity? Or is it an API for many languages?

I read through the docs and I guess I missed the point on the language used.

It says it has iOS deployment, would this still allow the programmer to code in objective C?

Is Unity an sdk which can be used for many platforms or how does it work? It mentions deploy the same code on multiple platforms.

onof
  • 17,167
  • 7
  • 49
  • 85
some_id
  • 29,466
  • 62
  • 182
  • 304

12 Answers12

130

All development is done using your choice of C#, Boo, or a dialect of JavaScript.

  • C# needs no explanation :)
  • Boo is a CLI language with very similar syntax to Python; it is, however, statically typed and has a few other differences. It's not "really" Python; it just looks similar.
  • The version of JavaScript used by Unity is also a CLI language, and is compiled. Newcomers often assume JS isn't as good as the other three, but it's compiled and just as fast and functional.

Most of the example code in the documentation is in JavaScript; if you poke around the official forums and wiki you'll see a pretty even mix of C# and Javascript. Very few people seem to use Boo, but it's just as good; pick the language you already know or are the happiest learning.

Unity takes your C#/JS/Boo code and compiles it to run on iOS, Android, PC, Mac, XBox, PS3, Wii, or web plugin. Depending on the platform that might end up being Objective C or something else, but that's completely transparent to you. There's really no benefit to knowing Objective C; you can't program in it.


Update 2019/31/01

Starting from Unity 2017.2 "UnityScript" (Unity's version of JavaScript, but not identical to) took its first step towards complete deprecation by removing the option to add a "JavaScript" file from the UI. Though JS files could still be used, support for it will completely be dropped in later versions.

This also means that Boo will become unusable as its compiler is actually built as a layer on top of UnityScript and will thus be removed as well.

This means that in the future only C# will have native support.

unity has released a full article on the deprecation of UnityScript and Boo back in August 2017.

danesh
  • 39
  • 6
Cody Hatch
  • 8,857
  • 6
  • 29
  • 36
  • 4
    Up vote what I think is the best answer. Just to make sure I'm reading it right, so I can write a game in unity using JS and then run it on an iPhone or Android device because it converts JS to objective-c for you? Thanks. – Ryan Aug 11 '11 at 20:51
  • 4
    Yep! You can only write in JS, and end up with a game that runs on Windows, OS X, a web browser plugin, iPhone, Android, PS3, and Wii. (Note: All but the first three require additional licenses.) – Cody Hatch Sep 01 '11 at 07:18
  • @CodyHatch "Depending on the platform that might end up being Objective C or something else" nope. For iPhone builds, Unity has some built in Obj-C boilerplate to interface with some cocoa-touch frameworks, but all of your code is compiled into Arm Assembly. Also you totally can write Objective-C plugins to do stuff like payments and notifications. – Stephan van den Heuvel Dec 17 '13 at 17:17
  • 1
    "Newcomers often assume JS isn't as good as the other three, but it's compiled and just as fast and functional." - sorry for ressurecting an old thread, but I must say this part is absolutely wrong. I run several benchmarks and JS works much slower than C# (up to 100 times in heavier computations). I recommend C#. – Przemysław Wrzesiński Jun 08 '14 at 20:25
  • Is this answer still up-to-date? – temporary_user_name Jul 13 '16 at 16:42
  • 2
    @Aerovistae I know this is late, but as of 2018, UnityScript and Boo are totally deprecated. They will eventually be completely spiked, as Unity believes that few people are using these languages anymore. C# is set to be the sole language of Unity, so there is no choice in the matter anymore. See this [blog post](https://blogs.unity3d.com/2017/08/11/unityscripts-long-ride-off-into-the-sunset/) for more info and [this Github repository](https://github.com/Unity-Technologies/unityscript2csharp) for a tool from Unity that is supposed to convert UnityScript to C#. – GDP2 Apr 17 '18 at 05:28
  • Thank you! Always better late than never – temporary_user_name Apr 17 '18 at 05:51
45

As far as I know, you can go with c#.

You can also use the obscure language "Boo". (Found at https://boo-language.github.io/)

In the past (before about 2012) it was possible to use a strange variant of Java but that is now deprecated and does not work.

Note that Unity builds to Android / iOS, and many other platforms. The fact that iOS programming uses objective-c or Swift, is, completely irrelevant at the Unity3D level. Unity is programmed using c#.

Community
  • 1
  • 1
Andreas Wong
  • 59,630
  • 19
  • 106
  • 123
6

When you build for iPhone in Unity it does Ahead of Time (AOT) compilation of your mono assembly (written in C# or JavaScript) to native ARM code.

The authoring tool also creates a stub xcode project and references that compiled lib. You can add objective C code to this xcode project if there is native stuff you want to do that isn't exposed in Unity's environment yet (e.g. accessing the compass and/or gyroscope).

Calvin
  • 4,177
  • 1
  • 16
  • 17
5

Unity3d supports C#, Boo and JavaScript. The framework translates this into its intermediate format and later to the desired platform (IOS/Android/Linux/Windows)

Keep in mind, C# Scripts are compiled first, followed by JS and Boo Hence if you want a C# script to interact with a JS, you ll have to keep the JS in the Standard Assets Folder.

3

Unity supports:
1. UnityScript(Is known as Javascript but includes more functionality for the Unity game engine. I think this could be very easy to learn)
2. Boo (No experience)
3. C# (I prefer this as it is useful to learn and you will be able to use this outside of unity as well. I also think it is easy to get used to)

alexo1001
  • 177
  • 2
  • 2
  • 11
2

Some of the core differences between C# and Javascript script syntax in Unity.

http://unity3d.com/learn/tutorials/modules/beginner/scripting/c-sharp-vs-javascript-syntax

but keep in mind C# is the best one to develop in unity

Pete
  • 57,112
  • 28
  • 117
  • 166
Muhammed Albarmavi
  • 23,240
  • 8
  • 66
  • 91
2

right now only C# can be used for scripting support for Boo and Javascript was removed.

IbrahimTG99
  • 149
  • 1
  • 10
1

You can use C#, Javascript, Boo.

Unless computing requirement for the function you write cause heavy load on processor, Javascript gives good enough performance for most cases.

1

It uses c#, and unityscript(javascript), which is supported by the source code in c++, and c++ plugin support(source code, and plugins require pro).

The unity3d script reference is really easy to understand/use if needed, probably the easiest out of engines like cryengine, udk, etc.

Hope this helps.

user3210251
  • 161
  • 1
  • 2
  • 9
1

One can use any one of the following three scripting languages:

  1. JavaScript
  2. C#
  3. Boo

But my personal choice is C# because I find it faster in comparison to other two.

m4rtin
  • 2,445
  • 22
  • 34
  • 4
    Could you explicit your answer ? Why do you think C# is faster in comparison of the other two ? Please provide references. – m4rtin Aug 19 '14 at 17:53
1

I remember this from reading some articles about performance in Unity from internet which was warning JavaScript users from using it in Unity about really massive issues of using JavaScript in unity instead of C#, it says that C# is almost 4x faster than JavaScript!.

I really appreciate that article because it saved me when I was about to start gaming, I don't mean that JavaScript is bad for unity developers , it is good but my advice could be that if you like using JavaScript, you should use it for simple small games NOT FOR BIG PROJECTS because it really can be a big problem!

halfer
  • 19,824
  • 17
  • 99
  • 186
amdev
  • 6,703
  • 6
  • 42
  • 64
0

As I know,C# is the most common in Unity development,it allows you do make different functions and commands easily.

UnityScript,just similar to Javascript,is being removed by the unity according to this by Superpig:

we are looking to get rid of UnityScript at some point.

However,UnityScript is not a good choice because it's just a langauge that uses javascript syntax with C# format,that make it strange and is not the best choice for game development.

Besides,other .NET languages can be used with Unity if they can compile a compatible DLL is also OK.See this link.