Learning Unity

My day job is now trying to fix things in Gunpoint and writing e-mails, both of which I’m pretty bad at, so in my spare time I’ve been learning Unity. Not making anything in particular yet, just following tutorials – my test project above has been charitably described by my friends as Thomas Was At Gunpoint.

I have a question, for anyone who uses Unity. I’m looking for a code editor that at the very least:

– Will make auto-complete suggestions as I type for Unity-specific functions
– And show info on what parameters they take once I’ve typed them
– Works on OSX

And ideally:

– Colours recognised Unity terms differently to, say, my own variables
– Makes autocomplete suggestions for my own variable names
– Works on Windows

To illustrate, here’s what I’ve tried so far and why it’s not ideal:

MonoDevelop (default)

– As I type ‘Destroy’, a standard Unity function, no autocomplete suggestions come up.
– Once I’ve typed ‘Destroy(‘ it recognises the function and pops up telling me what parameters it needs – ideal.
– But even then, it doesn’t colour the word ‘Destroy’ differently to show it recognises it, making code less readable.
– It does offer autocomplete suggestions for custom variables – ideal.

Unitron (included)

– As I type ‘Destroy’, autocomplete pops up and suggests the full function name – ideal.
– But if I type ‘gameObject’, autocomplete pops up, the first suggestion is ‘Game’, and it CHANGES the case of what I’ve written to match that, even if I don’t select anything from autocomplete. This actually breaks my code. What the fuck.
– Once I’ve typed ‘Destroy(‘ it doesn’t pop up with any help about what kind of parameters this function takes.
– It doesn’t offer autocomplete suggestions for custom variable names.

Sublime with Unity packages

– As I type ‘Destroy’, no suggestions come up.
– Once I’ve typed ‘Destroy’, it recognises it and gives it a special colour – ideal.
– Once I’ve typed ‘Destroy(‘, it doesn’t give any info on what parameters it takes.
– As I type one of my own custom variable names, it suggests that – ideal.

Right now I’m using JavaScript, but I could switch to C# if that’s the only way to get all these features in an editor. It just makes learning so much faster and nicer if the tool is always suggesting the correct name, explaining how to use it, and eliminating most of my typo- and case-related errors.

Any help much appreciated in the comments or on Twitter.

24 Replies to “Learning Unity”

  1. I don’t use Unity myself, but from all I’ve heard your best bet is to switch to C#. The editor support is vastly better, and nearly all libraries support it where they don’t support Javascript. Certain things like reading and writing text files and XML will be easier with C# down the road as well.

  2. Use C#. Unity’s JavaScript isn’t JavaScript – it’s UnityScript, which bastardises it and takes out half the fun features. It’s also a pain to optimise on IOS, so I hear.

    Use C#.

  3. Hi, unity developer/programmer here, first of all drop javascript.
    A) it makes your job harder to learn.
    B) unity developers in the beginning used javascript for their scripts and so on, but they have switched to C#
    C) javascript isn’t javascript, which is both good and bad, what I mean by this is that unity javascript while it’s called javascript isn’t in fact the same javascript one uses in websites, this is bad since if you go and look code online you might end up looking code that wouldn’t really work, and it’s good because javascript is considered by the programming community in general as awful to say the least.
    D) there is a lot more resources both related to unity and programming in general for C# than for unity javascript
    E) It’s a better language

    Now that you dropped Javascript and started to using C# I will move to the questions and additional help.

    For the IDE you will want to use visual studio, it’s by far the best IDE around, and it fits quite nicely with unity, that being said you will end up going back to monodevelop when you want to debug since it allows you to pause the code, go line by line and so on, while visual studio doesn’t allow that by default.
    As for the version of visual studio you can use the express version but it won’t allow you to automatically jump into the code, what I mean by this is that if your code throws an error in unity you won’t be able to just press that line and automatically launch the visual studio, open the class where the code is, and go to the line where the error is. To accomplish this you will need visual studio ultimate, although I believe if you have visual studio express already opened, it will go to the code line for you (might be wrong, never really used visual studio express).

    If you end up buying visual studio ultimate (or even if you end up using express), please try the 2010 version as well, since in my opinion and in a lot of other people opinions the color scheme in the 2010 is much nicer to work with, so it will definitely be worth trying before buying.

    Now for some useful resources:
    https://www.google.com/cse/home?cx=001712401338047450041:csfhqk-trfa <- this is the most useful link you will ever have while using unity, you will use it constantly, if you need to know something type what you want to know and you will get search results with stuff only related to unity, trust me it's no exageration when I say you will use it constantly.

    http://docs.unity3d.com/Documentation/ScriptReference/index.html unity documentation, you will also use that a lot, it's the MSDN of unity, it's extremely well documented, and it will tell you everything you need to know about the classes and methods that come with unity, you can also just use the previous link, since it will end up taking you to the appropriate link anyway.

    http://blogs.unity3d.com/ unity blog not necessary to develop, but many times they end up showing tricks, or information about upcoming versions and stuff like that.

    if you need any more help just reply here or hit me on my email which is micaelmor (it's a gmail email, I just don't type the rest because of web crawlers)

    P.S. The reason why it doesn't show autocompletion on destroy() might be because you are not trying to use that method inside Update(), or Start(), or LateUpdate() or one of the different places where unity executes your Code.

  4. I already replied via Twitter, but I highly (very highly) suggest UnIDE https://www.assetstore.unity3d.com/#/content/6070 for editing code directly inside of Unity. It works *almost* perfectly (it is still being updated), it increases efficiency, and it is very simple to use (not slow and bloated like I feel MonoDevelop is).

    It is worth a look-see, the demo is free in the Asset Store. I suggest Googling it or searching in the store.

    Awesome that you are learning Unity! Get UnIDE and you will be set! Have fun! I love Unity…

  5. Oh I skipped one of the requisites which is working for OSX, which visual studio doesn’t do (to the best of my knowledge), so yeah you will have to go with monodevelop, there are other options like eclipse which is a very used IDE for java, but honestly I doubt it’s worth using it.
    As for the suggestion of Evan, it’s nice but I don’t think it’s a replacement for an IDE, also since money isn’t that much of an objection, I would strongly advise you buy a second monitor, it pays for itself since it improves your workflow a lot.

  6. Have you considered using Vim? Bit of a steep learning curve, but any program that is still this popular amongst pro devs after more than 20 years is surely doing something right!

    You will need to customise it to get it working how you like with Unity but a quick Google search should sort you out…

  7. Coda 2 would do what you’re asking, but it doesn’t look like there’s a Unity module for it (there is one for javascript).

    You could also try Textmate, although the Unity module for that looks a little stale.

    As an aside, I’m surprised to see so many people warning you off Javascript. Almost all of the sample code available is in JS.

    Note: I myself have only dabbled with Unity, so take that with a pinch of salt.

  8. BBedit is widely recommended for its insane highlighting and hinting on Mac, and you may overlook it because its marketing is primarily oriented toward web development. I checked – it does have a Unity3D plugin, and some Unity developers do use it.

    If it were me, I’d try to hack up Vim since you get lots of bizarre powers and cross-platform functionality for free, and for better or worse these days they’ve increasingly abandoned the modal interface paradigm. Note that I do not claim I would ever get productive. It looks like you would want a Unity and C# combined .vim for the powerful custom highlighting half and one of a variety of tools with ctags for the function ‘prototypes’/’hinting’ half.

    Overall Intro: http://vim.wikia.com/wiki/Use_Vim_like_an_IDE (and See Alsos under Code Browsing)

    Ctags Howto: http://www.thegeekstuff.com/2009/04/ctags-taglist-vi-vim-editor-as-sourece-code-browser/

    Or assuming you don’t care about language anostism, Clang-complete for C#: http://stackoverflow.com/questions/11300788/vim-function-hints-for-c

    Highlighting customisation: http://stackoverflow.com/questions/736701/class-function-names-highlighting-in-vim

  9. Ninja foodstuff depending on what you are talking about, old examples is sometimes only in javascript (which is unityscript, not actual javascript), but most of the stuff in what concerns documentation is in all the languages unity support, you have an option to change the language in which you are seeing the documentation, and both the community and the developers of unity basically made the switch to c#, that’s not to say you won’t find things in javascript (unityscript), but these days they are a minority, and this is before we take into account the amount of code one can find for c# that isn’t related to unity, which is obviously a lot more than that of unityscript.

    Looking at the list of request, most IDE’s will do what he requires by default, the biggest problem and something that is not going to come by default is “Colours recognised Unity terms differently to, say, my own variables” which I assume he doesn’t mean just differentiating between unity methods from his variables, but also differentiate unity methods from his own methods.
    I also see them as somewhat of a non problem mostly because from a programming standpoint it doesn’t really add much to make such a distinction, it’s all objects and they are used in the same way that user made methods are, and differentiating between variables and methods is done by the c# semantic and code organization.

    BTW forgot to say in my initial post, but not sure if game maker allowed OOP, if it doesn’t, and you don’t really know about it, you should probably learn it, a good C# book that might help (it’s not unity related, but most of the information translates) is head first c#.

  10. Micael, I would be surprised if he does not have a second monitor! Haha! (He might not though, maybe you have information I do not.) Anyway, though UnIDE is still in development and very simple, I see no need for an external “IDE” if you are working with Unity. Personally, working with Unity, I do not need much out of IDEs. I think that is why so many people use simple text editors… Every one to their own I suppose! UnIDE is great but simple. For external IDEs I suggest Sublime Text. It is not for everyone but many like it.

  11. I’m not sure if he has one or not, but he posted some images of his house when he got robbed, and I don’t remember seeing two monitors, then again I remember seeing him use a television as a monitor, so technically to the best of my knowledge he had none XD.

    Well you don’t need an external IDE, but depending on how you work, it can be very useful, since they usually offer a bunch of tools that help like code refactoring, code analysis, XML autocompletion for methods (and similar stuff), class outliner, and the most important thing (although without addons is only available in monodevelop) proper debugging.
    I should probably mention that I have never used UnIDE, so the features I know are the ones I saw, it might have more and so on, and in my case I spend a lot more time refactoring, thinking on how to implement code, testing and so on, than I do actually writing it, so those features end up being more important to the way I do things, but I can definitely see how something like UnIDE can be useful, especially to quickly write something.

    BTW I feel that someone should mention in case that it isn’t obvious by now, that IDEs are very much one of those things that also ends up depending heavily on user preferences.

    P.S. Does anyone here use monodevelop frequently? I only use it for debugging, is it really that awful performance wise? I mean I know it had stupid stuff like it becoming very slow if you had a search on, but how slow is it these days on a nice machine (quad core, SSD, and so on)?

  12. I forgot to include, then meant to add before I passed out last night, that Cream is a Vim with the modal interface tucked away.

  13. I’m not sure how deep your Sublime knowledge is, but you can get a lot of extra mileage from its plugin system.

    This link (note: apologies in advance, I only googled for sublime and unity, so you may have already checked this out and found it wanting, and I’m not 100% it’ll cover what you need. For instance, the auto-complete for common Unity classes and functions seem a little light. Also, as Sublime is in the main just a very advanced text editor, it’ll probably have difficultly figuring out which functions and variables any given instance will have access to) lists a Unity 3D plugin for Sublime.

    http://www.holoville.com/blog/?p=512

  14. As said higher ( and to my knowledge ) MonoDevelop is the only IDE that allow you to debug Unity code ( by setting breakpoints, stepping, adding watch … ). There is one plugin for Visual Studio that does it too ( but require a visual studio pro licence, the plugin is not free, and only Windows ).

    For the auto-completion both Visual Studio and MonoDevelop show me “Destroy” if I start typing “Des” ( on windows ). Again as said higher in the comments, auto-completion is context sensitive which means that the IDE will not show Destroy if it “doesn’t exist in the class context” ( in this case to use Destroy, the class must be a child of MonoBehavior ).

    The shortcut “ctrl + space” forces auto-completion to happen.

    And I also recommend using C#.

  15. Haha, I’m sort of new to Unity and my first thought when reading this was;

    “Tom Francis uses Javascript? I use C#, but maybe he knows something I don’t…”

    Thank you, the comments, for immediately and repeatedly reassuring me.

  16. Cheers everyone. MonoDevelop’s autocomplete problem turns out to only happen in JavaScript – it works fine in C#, so I’ll switch to that.

  17. Now that you’re using C#, something that might also help is the tripple forward slash (///). It creates a comment block that will be used by MonoDevelop to show extra info in the info box.

    You can also use it to generate documentation using a tool like Sandcastle Help File builder, although that’s a bit awkward to use.

  18. Good one on switching to C#. Unity’s javascript is not real javascript and C# can serve you well outside of Unity. And it is just a better language in general, imho.

  19. You can also get Xamarin Studio, which is the most current version of MonoDevelop. The Monodevelop delivered with Unity with very very old. It has less bugs, better code completion, better syntax coloring, less bugs and less bugs. Also, since a few days, you can install a Unity Debug plugin from the Add-In manager (after you activated the add-in alpha channel repository).

    http://xamarin.com/studio
    http://www.cliffordroche.ca/monodevelop-4-xamarin-studio-debugging-in-unity/

  20. Hi Tom, really looking forward to what you come up with in Unity after the success of Gunpoint! I run the Learning team at Unity, so if you need a hand with anything feel free to give me a shout either via mail on will at unity3d dot com or on twitter @willgoldstone.

    All the best, and glad to hear you jumped to C#… so much better ;)

    Cheers

    Will

Comments are closed.