Discussion in 'Scripting' started by JacobPennock, Mar 19, 2012.
Great news. About to give sublime a go tonight as I have now had enough of the latest MonoDevelop.
Installed ST3 with the Unity package posted by oferei (awesome, thanks!)
Everything is great now except for autocompletion of my own classes.
I have CompleteSharp installed (pulled from git and compiled using python 2.7) and set up paths for my csharp assemblies but no go. Does it work with ST3?
I'm trying to get completions in Sublime, but it's not going so well for me. I've read all the blog posts and watched the video, and they seem to be about getting Unity's engine stuff to work. That's cool and all, but what I really need is for it to work on all the code in the project—Unity's libraries and my own code.
I've installed completesharp from package control. I've tried setting the "completesharp_mono_path" to both Unity's mono and Monodevelop's mono. Neither are working for me. I installed mono (v 2.10.11) and it bombs out with the same error as Monodevelop's version.
If I type something like "transform." the moment I hit the period I get this error in the console:
stderr: Loading: /Applications/Unity/Unity.app/Contents/Frameworks/Managed/UnityEngine.dll
stderr: Exception: Could not load file or assembly 'UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
stderr: at System.AppDomain.Load (System.String assemblyString, System.Security.Policy.Evidence assemblySecurity, Boolean refonly) [0x00000] in <filename unknown>:0
stderr: at System.AppDomain.Load (System.String assemblyString) [0x00000] in <filename unknown>:0
stderr: at (wrapper remoting-invoke-with-check) System.AppDomain:Load (string)
stderr: at System.Reflection.Assembly.Load (System.String assemblyString) [0x00000] in <filename unknown>:0
stderr: at System.UnitySerializationHolder.GetRealObject (StreamingContext context) [0x00000] in <filename unknown>:0
stderr: at System.Runtime.Serialization.ObjectRecord.LoadData (System.Runtime.Serialization.ObjectManager manager, ISurrogateSelector selector, StreamingContext context) [0x00000] in <filename unknown>:0
stderr: at System.Runtime.Serialization.ObjectManager.DoFixup s () [0x00000] in <filename unknown>:0
stderr: at System.Runtime.Serialization.Formatters.Binary.Obj ectReader.ReadNextObject (System.IO.BinaryReader reader) [0x00000] in <filename unknown>:0
stderr: at System.Runtime.Serialization.Formatters.Binary.Obj ectReader.ReadObjectGraph (BinaryElement elem, System.IO.BinaryReader reader, Boolean readHeaders, System.Object result, System.Runtime.Remoting.Messaging.Header headers) [0x00000] in <filename unknown>:0
stderr: at System.Runtime.Serialization.Formatters.Binary.Bin aryFormatter.NoCheckDeserialize (System.IO.Stream serializationStream, System.Runtime.Remoting.Messaging.HeaderHandler handler) [0x00000] in <filename unknown>:0
stderr: at System.Runtime.Serialization.Formatters.Binary.Bin aryFormatter.Deserialize (System.IO.Stream serializationStream) [0x00000] in <filename unknown>:0
stderr: at System.Runtime.Remoting.RemotingServices.Deseriali zeCallData (System.Byte array) [0x00000] in <filename unknown>:0
stderr: at (wrapper xdomain-invoke) CompleteSharp/MyAppDomain/Hack:Load (string)
stderr: at (wrapper remoting-invoke-with-check) CompleteSharp/MyAppDomain/Hack:Load (string)
stderr: at CompleteSharp+MyAppDomain.LoadAssemblies () [0x00000] in <filename unknown>:0
Here's what my complete sharp settings look like:
// commented out because I installed mono and now it's in my path
// "completesharp_mono_path": "/Applications/Unity/MonoDevelop.app/Contents/Frameworks/Mono.framework/Versions/Current/bin/mono",
I commented out setting the mono path after I installed mono. I'd love to use sublime, but without actual completions I can't.
It says it can't find the file, but it's definitely there. It's not a permissions thing because I've made a directory with global read access and get the same thing. Perhaps there's a dependency it can't find? Why would I be the only one to have this problem?
Searching this thread I haven't found how to sync ST projects with Unity 4 projects for OSX. Anyone have any success here? If so, could you share? Would really love to hook these two up, I think they're made for each other.
Note: I have all of the syntax, build and snippets packages installed in ST.
Thanks for your time guys (shouts to Jacob, rstehwien, pabu, joseph, oferei [your Unity Completions install hangs on my mac], and all others who have contributed to this effort), hats off to you all.
Perhaps creating a separate project in ST may help. It won't be synced with Unity, but it can easily be set up to work fairly well.
To create a project in ST open Project => Save Project As. Save it to the root directory of your Unity project (outside of Assets). Then open Project => Edit Project and edit it to something like this:
This will include only files under Assets/Scripts in ST and exclude .meta files. You can add more folders to the list (comma-separated) or instead include the entire Assets folder, if you prefer.
Note: ST will also create a .sublime-workspace file next to the project file. Do not include it in source control.
ive also just discovered Sublime Text and already am inpressed and want to throw everything else in the bin!
but auto completing own classes?! is it possible?
robot ink? any luck?
Man!!! you are my men!! I was just thinking on replace mono with sublime.. you must know why.
Thanks for sharing all these info, you save our life!!
You no longer need to do any of this as:
Sublime Text 2"$(File)":$(Line)
And using package control for syntax highlighting and everything else covers all you need. Thanks to OP for getting us this far in the past, but now there's native support most people should not need to hack anything together.
Ha, awesome I haven't looked in those options for a while, I had no idea they'd changed.
Hey I found a cool thing the other day that others might find cool, if you put
in your user preferences file, you don't have to save anymore! Kinda cool when you get used to it.
Awesome! Now that there's a bit of native support, could someone writeup an updated summary on all the steps of getting ST2 or 3 working with Unity? I'm kind of confused on what's needed and what's not now.
Yes +1 on that. Would be great to get the current state of play on this. As I'm getting more and more annoyed with MD's bugginess.
If anyone can post an updated tutorial on getting ST2 or 3 working well with Unity, I'll paypal them like $30!
Well I did register on Unity Wiki just to add a summary of what is in this thread, which I haven't done, so I might as well do it.
Do note that I am on Linux, while it has a Linux version of Sublime Text it harder to setup since Unity does not have an Editor for it. But I still managed to get C# autocompletion working on Mono and Unity Class Types.
Managed to write up on autocompletion topic, but not syncing and build systems*. By how much I took space compared to other editors in the wiki page, I guess it has to get its own page.
Unity Wiki  relocated
* - Someone on OS X or Windows should write about it
I had a problem with completesharp, similar to many others ;
"stderr: Loading: C:/Program Files (x86)/Unity/Editor/Mono/Managed/UnityEngine.dll
stderr: Exception: Could not load file or assembly 'UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified."
I tried several version of completesharp, recompiled them, etc. NOPE Finally, the problem was the path ; I reinstalled Unity in C:/Unity (no spacing) and everything is working fine.
So for all my windows fellows : be carreful, seems that Completesharp is not handling the path quite well (I checked the C# code, which uses FileInfo to load the file, it looks clear, so I guess it was my syntax in the config file which caused problems).NOPE
Edit ; Well, it seems that solving this error created a new one ;
TypeError: 'str' does not support the buffer interface
My guess is a bad compatibility between ST3 and CompleteSharp. And sadly, its creator new project, Completion, is not yet compatible with Windows ...
Edit 2 : I switched back to ewilde version of CompleteSharp, and I can get the plugin half working. My errors about some of the dll files came back (so it was NOT the path after all ..., or partly). Recompiling the .py files is not helping, again (btw, the unittest.py file is causing some compilation error, because of its syntax).
Edit 3 : Well, history repeats itself ! After tweaking my repertory, the buffer interface error is coming back (and completion is not working). As far as I understand it, it should be a python 2 vs Python 3 error.
Luckily, it seems that fate is on my side ; https://www.dropbox.com/s/o8chv5lnl2858eo/2014-05-11_14-43-41.png
I will test the completion plugin for ST3, and will keep you updated !
Sometimes the code of CompleteSharp Python script needs to be recompiled when changing project settings, I do this by just adding a space somewhere int the CompleteSharp.py script, see if that makes a difference.
I also have the RDeluxe's first problem with this package after reinstalling Sublime Text, but having a path without spaces doesn't fix it for me, though in my case I am using a shortcut/symlink(Linux) to the Unity folder. I check the path that it shows and it is correct. But what I really don't understand is why some of the DLLs that it is trying to load show a version other than "0.0.0.0" and why only mscorlib.dll is the only one that loads.
RDeluxe, even subscribers to this thread don't receive notifications when posts are edited. So please post your updates instead of editing them. That way you will get us up to date.
Well that python script or executable act very weirdly, it launches the CompleteSharp.exe twice when I write a dot after a variable. At first it seems to skip the libraries and tries to find the Type with initial mono libraries, then does it again with included libraries. Says that it is unable to find my given libraries, yet is still able to autocomplete them.
I noticed it doesn't recognize 'float' and 'double' value types, because they are the written in lowercase. But there is already a function within the python script that replaces them with correct classes, eg. 'char' => 'System.Char'. I added all value types to the script and commited those changes to github, my forked repository - https://github.com/Pendrokar/CompleteSharp
TypeError: 'str' does not support the buffer interface
I only get this error when adding or removing a library from project settings. Recompiling the python script seems to clear a cache, making it reload all libraries.
Unfortunately this looks like it's Windows only right? I was able to get everything else working, this is the last piece I'm struggling with..
Seems so "External Script Editor Args - Windows only.". But you could create a shell script and use that as the editor, which would launch Sublime and add the necessary arguments that Unity sends, if any(on a Mac). Note that I don't have a Mac and run Unity in Linux through Wine.
 Format of shell scripts seems equal to Linux, here is something that could work.
# Change '/opt/sublime_text/sublime_text' to the path to your executable of Sublime Text.
# Sublime Text 2:
# "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" $1:$2:$3
# Sublime Text 3:
"/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" $1:$2:$3
echo "Opening '$1' on line '$2' column '$3' with Sublime Text"
[edit2]Save this to a file and make it executable(if needed). Then attach the file as the script editor in Unity preferences.
[edit3]Changed ST path found in OSX command line...
Thanks for giving information.
Thanks man for the plugin
Anyone get Sublime text to jump to error using mac?
Sublime Text 3 does that!
@petey does yours jump to line as well? if so, how? (I get appropriate file only.)
Are you using ST3? (beta)
Does this mean the solution I have provided in my previous post does not work for Mac OS?
I'll do edits to make it clearer...
It works now. Didnt work in ST2.
One thing though is that I am trying to follow the Wiki and it says use package control to install completeSharp but I can never find it when searching in ST3. What should I do?
Also,how do I find out what the 'path to Unity folder' is?
I see thanks for letting me know, I'll add it to the wiki.
The original creator of the package removed it? Doesn't seem so.
Although it doesn't have ST3 tag, but that never made ST3 skip it.
I see that I haven't noted that the package should be installed by following the README file. Use 'ewilde's version:
In the README it states to go to packages folder, easiest way to find it is with Preferences -> Browse Packages
This thread has had Mac users. In one post I see that the folder structure is quite different from Windows:
 edited wiki page
This is a stupid question, but how do I know it worked? I can't tell, I get no errors (I never received any even with the wrong path file).
If you're using UnityScript or Boo (or if you can't get CompleteSharp work on ST3) you're more than welcome to use the Unity Completions package, which I wrote. It provides auto-completions for all 3 languages, though it does not parse the code (it's a little more naive).
also: it's quite a large package (contains all completions built-in) so installation takes a few minutes!
Thanks, but I need it to parse the code for me. I'm using C#.
Just managed to have Sublime Linter work with C# and Unity C# on Sublime Text 3:
That looks great Pendrokar!
I couldn't find the package (ST3 on OSX), i assume the csharplinter should work on osx as well as windows? Is there any special requirements for accessing it on package manager?
I haven't updated the readme file and as noted, a standalone linter called 'csharplinter' does not exist. I also haven't created a package for this, as the current setting might only work for Linux that has Mono installed. Windows and OSX users should try configuring it to use Mono installed by Unity. Edit: (perhaps I should too as I am using the Windows version of Unity in Linux, but my Mono version is almost equal to Unity's Mono)
I just uploaded what I have, as an official linter requires following strict guidelines:
That sounds great! Please keep us updated as to when the package will be accessible through package control.
just found this post. i use sublime, prefer it really, much faster in my eyes. but i am having trouble setting everything up for unity. i have changed the external editor, done. also did get hold of the plugins from the wiki on unity explaining how to get sublime to work. but the steps are not working for me.
could someone just make a list of what exaclty i need to get it running. the plugins, but vene any extra info such as settings?
would be good to have a post that just says all the steps, rather than going through these pages to find. to make it easier for others ,who may want to use sublime instead.
Sorry, but you are not being clear about what exactly doesn't work for you.
I have already structured the wiki page in a Step-By-Step way. I may add screenshots for newcomers to Sublime to understand what each section is about. The only warning I could give is about the settings files. The "..." at the beginnings of lines aren't meant to be copied, just what is between them.
Please note that the information here is very outdated.
I'm planning to write an article very soon about how to setup SublimeText 3 for Unity development (with C#). In the meantime take a look at this: http://www.omnisharp.net
Which is the reason I created the wiki page on Unity Wiki. It is meant as a summary of what you may find in this thread while also having the possibility to collaborate with the Unity community to make modifications and updates.
I'm against such articles, because they also might get out of date without a possibility for community to update it. Then again I am looking forward to it, if it includes information about what is OmniSharp and how to integrate it.
What I meant was that using CompleteSharp is not the best method and compared to Omnisharp is definitely an inferior (and therefore out of date) method.
After writing the article I don't mind putting it on the wiki as well. Just need to find the time to do it.
sorry if i wasnt clear. sometimes what i type is not what i mean. the errors of dyxsleia i guess
but im going to wipe sublime and start again. sometimes just have to. and try the wiki again. im more than 100% sure it works fine just what im doing is wrong
i see where im having problems. its at the first point. with the project setup.
the creation of the project is fine, but its the code to go with it. dont know really where to put it, plus it doesnt say where. im guessing its the setting in the user part. but dont know really
Ah yes, seems I somehow thought that "Save Project As" would open the settings file. It's through "Project" -> "Edit Project", the file that opens is the project settings file. I'll add it to the wiki when I can.
groove balls thanks
sorry for the delay (busy contract).
This was the second time I tried to move to ST3 for Unity3d/C#. Well, despite all quirks of MonoDevelop it's still much more powerful in terms of autocompletion and refactoring.
But I also encountered this project: http://www.omnisharp.net/
Has somebody tried it for ST and Unity?
Yes @luispedrofonseca has and planned to write an article about it, but hasn't gotten back to us. See his #238 post.
There is a community edition of Visual studio that works with add ons and UnityVS so you can just ditch monodev. Also it is much easier to bring the features people want from sublime to VS than it is to get sublime to work really well with C#.
I'm not a sublime fan but am a long time VIM user and was able to almost recreate my whole VIM setup in visual studio with a few add ons.
Also stock VS has better autocorrect and refactoring than monoDev than once resharper is added the refactoring gets even better.
But I can't ditch my Mac. I'm also an Objective-C developer and prefer my OS X development toolset.
I think I could try to run VS in Parallels - I used it for FlashDevelop years ago and it worked well.
Sorry, missed it.
I've started to use sublime again [im on mac myself]. MASSIVE difference really in terms of speed. i mean, when i save the file, UNITY reloads right way. on MONODEVELOP, i have to go into UNITY to have it reload.
i got the linter to work, which has been great. still a few things wrong, but hey, the speed is insanely quicker
i just wish UNITY would look at MONODEVELOP again and just get it fixed. i even tried XAMARIN and that was so fast. but took it off because of setup problems for UNITY.
even to get someone to do a proper sublime plugin for UNITY, that work at UNITY. i think it would be good. but then again, thats wishful thinking
but really MONODEVELOP needs to either be fixed, or look for something else. it does put down the UNITY experience when you have to use a different tool to what your given.
id love to use VS, but dont want to go a parallels path. id rather have a windows machine instead to do that. but that won't happen soon since all my software is mainly apple based