Search Unity

Eclipse, C#, and Unity

Discussion in 'Formats & External Tools' started by Krispy, Oct 10, 2007.

  1. Krispy

    Krispy

    Joined:
    Jun 6, 2005
    Posts:
    69
    So, I've been trying to start using Eclipse (with the Emonic C# plugin) with Unity, mainly for ease of debugging, unit testing, and integration with code repositories. I'm still stumped on how I get Eclipse to use the UnityEngine namespace, or, more accurately, how to actually get the UnityEngine namespace.

    Any help?
     
  2. Randy-Edmonds

    Randy-Edmonds

    Joined:
    Oct 10, 2005
    Posts:
    1,122
    Cool, I had not heard about the Emonic plugin. Im going to try it!

    Have you tried to right-click the project and add a reference to UnityEngine.dll Thats how I do it in Visual Studio. Then, of course, put "using UnityEngine;" at the beginning of every .cs file.
     
  3. Darko

    Darko

    Joined:
    Aug 28, 2007
    Posts:
    100
    You can debug with Visual Studio? You mean with Parallels?
    Could debugging work with Xcode? Or at least the editor with code-completion?
     
  4. benblo

    benblo

    Joined:
    Aug 14, 2007
    Posts:
    476
    Very interesting thread!!
    I'm also interested in knowing more about VS, big fan.

    I'm trying eclipse with emonic (thanks for the tip, if it saves me installing Parallels, Windows and VS, it could be worth the switch!), but I get errors whenever I try to open a script, I get an error (Reason: <blank>, check the details => ERROR... :D).

    Do I have to install Mono, or will Unity's version do?
     
  5. Lka

    Lka

    Joined:
    Aug 6, 2006
    Posts:
    297
    Yes, you can debug c# code in VS with Parallels, but calls to Unity dll won't work, you need to keep graphic code separed from logic code (with functions or conditional compilation).

    Something like this:
    Code (csharp):
    1.  
    2.     internal static bool IsWin
    3.     {
    4.         get
    5.         {
    6. #if WINDEBUG
    7.             return true;
    8. #else
    9.             return Application.platform.Equals(UnityEngine.RuntimePlatform.WindowsWebPlayer);
    10. #endif
    11.         }
    12.     }
    13.  
    With Unity2 you need VS2005
     
  6. benblo

    benblo

    Joined:
    Aug 14, 2007
    Posts:
    476
    Eeeew... that's ugly!
    You mean you can't reference the UnityEngine.dll in VS? or just that you can't compile and run the whole thing?

    Debugging aside, just using VS to do all the code completion (crawling my files and knowing the Unity API) would be a huge plus.

    Of course debugging would be an even huger plus but... well... good ol' trial and error is what gamers do anyway 8)

    I'm only 2 hours into eclipse and already I hate the code completion, it's so clumsy compared to VS.
     
  7. benblo

    benblo

    Joined:
    Aug 14, 2007
    Posts:
    476
    Forget what I said, I just tried a java project: eclipse's completion engine is really not that bad!
    It's emonic who's... well, not there yet.
     
  8. Darko

    Darko

    Joined:
    Aug 28, 2007
    Posts:
    100
    I still have hope in Xcode. There is a Mono C# plugin for Xcode. Did nobody tried this?
     
  9. Lka

    Lka

    Joined:
    Aug 6, 2006
    Posts:
    297
    :D
    Not that ugly!
    If you need only code completion you can reference the Unityengine.dll and code without #if.

    I utilize it to compile and run the application in Windows.

    Sorry for XCode, I dont'like it and I never tried it with Unity
     
  10. benblo

    benblo

    Joined:
    Aug 14, 2007
    Posts:
    476
    Very good news! Isn't it too bad to use VS with a mac keyboard?

    Now to get a copy of Parallels or VMware... any idea if VS2005 will run under CrossOver? Somehow I doubt it, but that would even save the Windows license.


    Wow... that's impressive!
    But how do you run it if you can't use graphics? Do you just run, attach a debugger, and see what happens without having anything render on screen?
     
  11. Randy-Edmonds

    Randy-Edmonds

    Joined:
    Oct 10, 2005
    Posts:
    1,122
    Actually I use VMWare Fusion to run Visual Studio. I have a shared folder setup in vmware to directly access the code files (assets) in my Unity project. Works great! I would prefer to use a native OS X ide as opposed to using a windows program. But so far I haven't found any IDE that can compete with Visual Studio... the code completion (intellisense) is priceless.
     
  12. Randy-Edmonds

    Randy-Edmonds

    Joined:
    Oct 10, 2005
    Posts:
    1,122
    NOTE: I only use Visual Studio to EDIT the source code. I never use it to compile or debug the code. I have found this isn't a big deal, because Unity compiles the code as soon as I save it in visual studio. I use unity's Print commands for debugging.
     
  13. Lka

    Lka

    Joined:
    Aug 6, 2006
    Posts:
    297
    It's like in Windows, I've only remapped the F9 and the F10 key in Osx.

    I've never attached the debugger to the exe generated by Unity and I don't know if it works. I've all cs files in a solution and a form with some buttons to debug specific parts of code, so I can debug it with breakpoints in VS.
    Graphics parts are debugged in Unity with Debug.Log calls.
     
  14. benblo

    benblo

    Joined:
    Aug 14, 2007
    Posts:
    476
    Very clever indeed!

    So I installed VMware, Vista, and VS 2008, bam, what the hell, might as well use all the latest versions!

    I works like a charm! My precious autocomplete is back and kicking ass!
    Also, I don't know if you guys know about this addin that allows you to link to a whole directory (it creates the directory structure for you and references all files as links). This way the integration with Unity is perfect.
    It's a 2005 addin but all you have to do is put it into the Addins folder in My documents\VS 2008, edit the .AddIn file and set <Version> to 9.0 instead of 8.0.
    Heck, I'll just zip the thing and post it here, I don't even think you need to download and install the MSI installer.

    BTW, WMware is just awesome, with the Unity feature (hey, the stole the name ;)), it's just seamless. You have to see the Windows windows (...) squeeze back in the dock to believe it.
    Vista is neat, I never had time to make the switch from XP on my PC but it's cool to see it on my Mac!
    And VS 2008 looks even cooler than ever, yay! Apparently they're making a VS shell to concurrence Eclipse... definitely, with this + Unity 2, 2008 is gonna be an awesome year!
     

    Attached Files:

  15. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,307
    Cool! You just made my day... In finally got into Unity and after one day of "playing around" I must say - it's really soooooo cooooool! Only thing that got at me was the missing Intellisense support... reminded me of those bad JavaScript and ActionScript days where I spent more time trying to figure out the spelling and what was available where, and then debugging ugly errors than actually implementing functionality.

    But with this wonderful thread, it seems I can use my VMWare Fusion WinXP + Visual Studio .NET 2005 installation just smooooothly.

    Guess I'm gonna get Pro today... 08/12 sounds like a cool date for that ;-) ... let's UNIFY the world :)

    Joyful regards,
    Jashan (who just got up at noon after being up until 3am last night, hehe)
     
  16. shaun

    shaun

    Joined:
    Mar 23, 2007
    Posts:
    728
    The Add Directory Content addin is awesome! It's totally made my day.
    Thanks Ben, if you ever come to South Korea, I'll buy u a beer, or a brewery! :D
     
  17. benblo

    benblo

    Joined:
    Aug 14, 2007
    Posts:
    476
    Glad you liked, but the real credit goes to the guy who created it.
    I actually don't use the addin anymore, I just put the project file directly in the root of Unity project (besides the Assets and Library folders).
    Either way, you need to manually update stuff in VS when you move files around anyway... still not perfect.

    South Korea isn't in my plans for now, but I guess I'll just have to change them... I just can't refuse a free beer ;) !
     
  18. shaun

    shaun

    Joined:
    Mar 23, 2007
    Posts:
    728
    I was using that method before - but I never got code completion to work for classes I wrote - It was fine for Refs that I added but not for anything with .cs files.
    I was using a Web Project though. Couldn't get things running as a normal VS project.
     
  19. Ricko

    Ricko

    Joined:
    Dec 9, 2007
    Posts:
    169
    I tried this with Parallels, Vista, and VS2008 and it works well for auto-completion, which is a nice time saver for me.

    Does anyone know how to set up VS in Parallels as the default script editor for Unity? The Unity Preferences panel seems to require a Mac OS application to be selected in a file browser as the default editor. The Parallels smart-select feature (opening certain files in windows apps based on file extension) seems to be overridden by the Unity preferences.

    Thanks,
    Ricko
     
  20. benblo

    benblo

    Joined:
    Aug 14, 2007
    Posts:
    476
    Wow, didn't know about that, any idea if this exists with VMware? I constantly double-click the debug console and of course Unitron shows up... very frustrating!

    Have you tried directly setting Parallels as the external script editor? Maybe then it'd redirect it to VS?
    I'd say it's either that or wait for UT to implement a "just let OS X open the file" option... or maybe even write a quick OSX app that would accept the script as parameter and then feed it to Parallels, or even OSX directly, kinda like .NET's System.Diagnostics.Process.Start... I suppose there's an equivalent in OSX.
     
  21. thomasvdb

    thomasvdb

    Joined:
    Feb 28, 2008
    Posts:
    85
    Does someone has a little tutorial how to set this up?
    I tried the addin from benblo (thanks!) but VS says he cannot find the UnityEngine... :oops:
     
  22. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,307
    Hi Thomas,

    have you tried searching the forums for VMWare Visual Studio Howto ? I had put a little tutorial in there just recently, including the instructions to get the UnityEngine.dll to be used by Visual Studio...

    Sunny regards,
    Jashan
     
  23. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,307
  24. benblo

    benblo

    Joined:
    Aug 14, 2007
    Posts:
    476
    I've been meaning to post this for a while but always postponed it, so hurray for forum notifications!
    So... here is the XML doc for the DLLs. Just drop them in the same dir as the DLLs, reboot VS just to make sure, and bam, you got yourself inline documentation!

    Not only will that save you hundreds of roundtrips to browser-based docs, but along with the power of Intellisense, it makes VS the perfect tool for learning the Unity framework while coding.


    For the curious, I put together these XML docs by parsing the HTML docs... tedious, and incomplete (the code samples are gone, also I never got the courage to drill down the functions to get parameter or overload-specific docs), but still great for quick info.

    I also had a macro to F1 a keyword directly from VS to the online doc, but since my VS2008 beta expired, I'm stuck with Express so no more macros :(.

    I accumulated a bunch of helper classes/scripts specifically made for C#, I feel so bad for anyone not using VS (or using JS) that I really want to put together a VS/C# starter pack... one of these days.
     

    Attached Files:

  25. thomasvdb

    thomasvdb

    Joined:
    Feb 28, 2008
    Posts:
    85
    Great !!
    Thanks guys!
    Will try this as soon as possible :wink:
     
  26. dschnare

    dschnare

    Joined:
    Feb 9, 2008
    Posts:
    8
    This sounds horrid to me. Like I mean just to develop with Unity at a sane level I should look at installing Unity, Parallels, Windows, and VS? Damn that's a lot of memory that gets eaten up. That seems like piss-poor way of doing things. Just my thoughts. I've been wanting to get on the Unity bandwagon for a while but I want to be able implement features outside the engine without the need of all this bloated MS software. I'd be interested in developing features as DLL assemblies that will run with the game whether it be deployed for Windows or Mac, or even a work-flow that would support this.

    Unity is pretty wicked. Love the idea of attaching scripts, but you have to be able to write systems and data structures outside the engine that will be used by the scripts without having to resort to installing a S***e-load of software. What about Mono?
     
  27. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,307
    Well, Unity does come with a nice text editor called Unitron which does support syntax highlighting. It's a nice editor, and probably all that many people need.

    However, it simply can't compete with a powerful IDE like Visual Studio. As far as I know, there's nothing that could compete with that (at least for developing C#) for the Mac, so it's just natural to do the setup with VMWare or Parallels if you want that power. If you add UModel, which has a plugin for VS, you even get full-blown UML support and can easily set up a really professional software-engineering process.

    And using VS doesn't mean your code only runs on MS!

    Basically, we're just using VS as a "really cool editor". Probably, the best one you could get these days... And if you go for the Express editions, it's even for free ;-)

    Mono is just a framework - and in fact it's the framework that Unity scripting is built upon. So, when I'm using VS, I'm basically just building code for Mono to run inside of Unity on any machine that Unity supports. One reason why I chose Unity is because from the API perspective (not from the implementation perspective), you can say .NET = Mono. There's no difference. If I'm creating assembly DLLs, they are dependent on the Unity Engine - not on any MS stuff.

    As IDE-alternative, there's Monodevelop... Not sure about this, though - seems like a few people didn't have a lot of fun with that on the Mac. Also, there's Eclipse, but that doesn't seem to work that great with C# (it definitely can compete with VS for Java, and Eclipse works natively on the Mac - but Java is not supported by Unity, and not really one of the top Mono/.NET languages).

    It really depends on the standards you're used to. If you're a Web developer, used to JavaScript and editors for JavaScript, maybe Flash and ActionScript, Unity with Unitron will look perfect to you and you may not even consider asking for more. If you are, however, used to Visual Studio or Eclipse, the code editing in Unitron will look to you like from the last century (which isn't that long ago, anyways ;-) ).

    Then, however, you really don't mind having Visual Studio running in a virtual machine to edit your code for Unity. In my case, Unity even does the compiling most of the time ;-)

    The only thing I'm missing in this is that while Unity jumps directly to the relevant code in Unitron in many cases, this obviously doesn't work with VS running in a virtual machine. Well, but I can live with that (that's why I sometimes do compile my Unity code in VS) ;-)

    Hope that clears up the perspective a little bit...

    Sunny regards,
    Jashan
     
  28. AngryAnt

    AngryAnt

    Keyboard Operator

    Joined:
    Oct 25, 2005
    Posts:
    3,045
    If you, like me, hate code completion then there's always SubEthaEdit for a very nice and straight to the point tool.
     
  29. thomasvdb

    thomasvdb

    Joined:
    Feb 28, 2008
    Posts:
    85
    Aaah it worked! Thanks holtsch... you're the best :wink:
     
  30. Randy-Edmonds

    Randy-Edmonds

    Joined:
    Oct 10, 2005
    Posts:
    1,122
    Understandable attitude. Many developers are comfortable with Visual Studio (and it is a great IDE), so having it available for coding Unity scripts is a valuable thing to many developers (regardless of all the hoops they have to jump through to make it work... vmware and shared folders, etc). If you don't want to go down that road, you could use MonoDevelop instead. It is still in "beta" for OS X, but I use it and haven't really* had any problems with it.



    *The only problem I had was that the default font didn't display correctly in the editor... it was easily fixed by changing the default font to something else.
     
  31. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,307
    Well, you're welcome - but I have to pass that on the community. After all, the only thing I did was collect and put together the suggestions I read from others in the forums (and added some stuff of my own... ok, I'll admit: I'm pretty cool :cool: ).

    Sunny regards,
    Jashan
     
  32. psynopticM

    psynopticM

    Joined:
    Apr 13, 2008
    Posts:
    6
    Hey everybody and thanks for all the info I found in this thread.

    Concerning the add-in that let's you use existing items in a linked mode (instead of VS copying it):

    Using VS 2008 Express (the free edition for those that don't know) you are going to have no luck using that add-in. However, no reason to despair:

    Adding existing items in VS 2008 (including express editions) gives you the option to add existing items 'as a link'. Simply mind the small arrow on the 'Add' button in the corresponding dialog ;)
     
  33. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,307
    Hi Ben,

    Hey wow - this is really cool! I've just put the two XML files into my project and this is really a very nice add-on :)

    It's a bit unfortunate that the Unity API does not really have a "standard" XML documentation, but this is really nice.

    Hey, that would be really cool! I've just started a Wiki article (basically for now just the little "how-to" I had already attached to this thread, but since it's on the Wiki now, it can be extended) - maybe we could work together on this?

    Sunny regards,
    Jashan
     
  34. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,307
  35. Lucas Meijer_old

    Lucas Meijer_old

    Joined:
    Apr 5, 2008
    Posts:
    436
    Wow, this vs2008 integration is totally cool.
    Now editing with inline documentation, code completion, perfect for a guy like me who has to look up every simple operation in the docs because I haven't done c# before.

    It's also great that you can use the vs debugger to debug the parts of your code that don't interface with Unity.

    Has anybody tried somehow hooking up the visual studio debugger to a windows standalone player, so that we could also debug the code that actually talks to unity?

    Bye, Lucas
     
  36. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,307
    Hi Lucas,

    I'm afraid that probably won't work. I think the Visual Studio debugger hooks into the MS .NET framework when debugging .NET applications. However, in a Windows Standalone, there's only Mono running, and I'm not even sure that's "plain Mono" or Mono somehow integrated with UT's engine code.

    I would love (and quite often *need*) debugging with the possibility to step into the script code with breakpoints, but AFAICS, this is currently not possible...

    Sunny regards,
    Jashan
     
  37. Lucas Meijer_old

    Lucas Meijer_old

    Joined:
    Apr 5, 2008
    Posts:
    436
    For anybody playing around with this with VS express, and can't get that plugin working, I've found it to work great so far to actually place the VS solution on the mac, and then make a symlink from the vs solution to my unityproject/assets/scripts folder. That way you can also add new scripts from visual studio.

    You can even rename/move them from visual studio, as long as you only do it for scripts that are not being used by unity. (read: not attached to game objects), since those reference will be lost when you rename/move.

    After working with this autocomplete, auto-documentation, and "Ill just write that for you" mentality of visual studio I'm very much impressed. It's so much easier to work with (at least when you're unfermiliar with the unity api, and with the .net api).
    It even sometimes finishes code for me in a way that I really have to think for a second or two.. "how the hell did it figure that out..."

    Made my day,

    Lucas
     
  38. aigam

    aigam

    Joined:
    Dec 31, 2005
    Posts:
    170
    Wow! its fantastic! thks!
    I have a mac and a pc, I love to use the mac only for unity while I'm using the pc with vs2008 to write all the code.

    I have the pc and the mac working in lan and it works fantastic.

    Thks for this, the wiki tip "Setting up Visual Studio for Unity", and the xml documentation.
     
  39. thomasvdb

    thomasvdb

    Joined:
    Feb 28, 2008
    Posts:
    85
    VMWare Fusion is great! :D
    I didn't know it can use your Bootcamp partition till now :p
     
  40. MauMau

    MauMau

    Joined:
    Jun 26, 2010
    Posts:
    41
    I know this thread is quite old, but I'm having a hard time to enable code completion for Unity on the Mac in Visual C# 2010 Express. Must admit that I am new to Mac, as well as VC 2010.

    This is my configuration:

    - Unity installed on MacBook
    - VC 2010 Express installed on Windows XP (using VMWare on the Mac)

    My Unity projects are saved in "Documents" on the Mac. This folder is set to "shared" in VMWare, so I can access it easily under "My Documents" in Windows.

    I don't work with projects in VC 2010, what I am used to do is to open a script manually, edit it and save it again. Once I saved it, Unity recognizes the change of the script automatically. Okay so far.

    However, I'd wish to enable code completion for the Unity syntax (which is the only reason I installed VMWare and VC Express) but I can't get it to work using the Wiki Guide. This guide mentions some mysterious DLLs which I can't find. I also don't have a clue where I should put them into. I wonder if this guide is somewhat outdated :(

    Could anybody give me a fool-proof hint how to enable the code completion?
     
  41. cannon

    cannon

    Joined:
    Jun 5, 2009
    Posts:
    751
    You need to dig into the Unity.app file to find the UnityEngine and UnityEditor DLLs.
    Copy it over to somewhere where VC can see it.
    Create a VC project in your Unity project folder, open it up and then add a reference in VC for the two DLLs. This will give you autocomplete for C#.
     
  42. cannon

    cannon

    Joined:
    Jun 5, 2009
    Posts:
    751
    CMD+click I think to open up the Unity.app instead of launching it.
     
  43. kapuca

    kapuca

    Joined:
    Oct 12, 2012
    Posts:
    2
    Hi folks, I know I know... this is a very old thread.. but I am trying to find something better to make unity code.
    I've tryed emonic, but I belive it is not traking eclipse evolutions, I've installed it on my eclipse indigo and could not create any projec using C# because there's a crash of "null pointer exception" :( yep that is bad.

    any tip ?
     
  44. maynull

    maynull

    Joined:
    Oct 26, 2011
    Posts:
    29
    Hi folks I've been trying to use VS on Mac for a while now

    I'm using Parallels and VS, Sync Monodevelop project opens the visual studio however do I need to add all Dlls manually everytime?

    I mean even after I add Unity Dlls I still lack others

    Is there any automatic way to do that ?
     
  45. pr.simmons

    pr.simmons

    Joined:
    Nov 28, 2012
    Posts:
    7
    Import Visual Studio XXXX.unitypackage into your project
    Now you will have a new menu, select the option to build the VS solution and all the references should be correct.
    Note that you may have to restart to see the new menu