In my last post about using Sublime Text 2 with Unity3D I covered how to get syntax highlighting working for C# and JavaScript. If that is what your are looking for you can find it here: Using Sublime Text 2 with Unity3D

In this post I cover some more tips on how to get Unity3D working with Sublime Text.

Including :

  • How to make sublime jump to the line number of problems found by the Unity debugger.   (Windows only)
  •   I’m also releasing a Sublime Text plugin called Unity Helper that lets you search the Unity script reference  from within sublime by entering a keyboard shortcut or by right clicking any Unity class or function. (all platforms)

 

How to make sublime jump to the line number from Unity debug console

Basically at the time of writing this Untiy3D 3.4 only outputs command line options for the built in editor (monodevelop).  The way most other editors have got around this is to write a small wrapper program that replaces monodevelop and passes the command line options on to the users editor of choice. As it turns out the wrapper that was written for Notepad++ works just fine with sublime text and will due the trick.  All you need to do is edit a specific ini file with Sublime Text’s details.

You can download a package with the edits based on my configuration (64-bit Sublime Text 2)

My Version, and jump down to step 3.

Or if you have a different configuration or are weary of downloading an exe off of a random blog you can do it yourself starting at step 1.

Step 1.

Go to the Unity Community wiki page for Using Notepad Plus Plus as a script editor scroll down to the bottom to the section that says “How to make Notepad++ jump to the correct line number from the error console” and download and extract the package that is linked there.

Step 2.

Open the extracted folder and find the file named wrapper.ini replace it contents with this:

[Settings]
Application=C:\Program Files\Sublime Text 2\sublime_text.exe
Arguments="*file*:*linenumber*"

you will need to change the Application line if you are not using the 64 bit version of Sublime Text 2.
Now rename the file UnityExternalScriptEditorHelper.exe to MonoDevelop.exe

Step 3.

Navigate to unity’s install of monodevelop, C:\Program Files (x86)\Unity\MonoDevelop\bin then rename the MonoDevelop.exe that is there to something else like MonoDevelop_Real.exe.

Step 4.

Copy the new MonoDevelop.exe  and wrapper.ini from the extracted files to C:\Program Files (x86)\Unity\MonoDevelop\bin .

Step 5.

Set Unity to use the built in editor. [Edit] -> [Preferences…]

Thats it! Now when you double click an error or warning from within the Unity Console window Sublime test should automatically navigate to the corresponding line.

 

The Unity Helper Plugin

This plugin give sublime text 2 the ability to search and look things up in the online Unity3D script reference documentation. Select any word, class, or function call and then right click and select Search Unity Reference to do a search on the selected term, or select Unity Class/Function Lookup to be taken directly to the script reference page for the class or function. You can also search the Unity script reference from within sublime text by using the keyboard commands:  Ctrl + Shift + P  then U to find the available Unity helper commands.  Preview video with more details coming soon.

Download :  Unity Helper

Install :  Extract the UniyHelper  folder and copy it to the Packages directory of your Sublime Text 2 install (on windows  C:\Users\<yourusername>\AppData\Roaming\Sublime Text 2\Packages) Then restart Sublime.

  • Tarique Naseem

    March 10, 2012 • Reply

    I came here looking for a solution to getting Sublime to go to the correct line number for Unity. Alas, I'm on Mac :( However, it gives something for me to go on and I'll see if I can drum up a solution, using what you've found.

    The UnityHelper works a treat though. On a Mac, just place the folder in ~/Library/Application Support/Sublime Text 2/Packages and you're good to go.

    • abstractmachine

      September 21, 2013 • Reply

      Sublime Proxy works well if you're on Mac. Make sure to recompile the code as the precompiled binary had some minor issues :

      https://github.com/thinkrad/SublimeProxy

      • Goon

        February 11, 2015 • Reply

        It seems like Sublime Proxy doesn't work anymore in Yosemite.

  • abstractmachine

    September 21, 2013 • Reply

    I had to change line 20 in the UnityHelper.py file in order to get "Unity Class/Function Lookup" working right on the Mac. For some reason it wasn't working with the Unity website, so while fixing that problem I decided to go with the local documentation (better when I'm working on a train):

    url = 'file:///Applications/Unity/Documentation/ScriptReference/' + text.replace(' ','%20') + ".html"

  • Juan

    September 24, 2013 • Reply

    Hey Man!
    This is awesome! I had a question though -- I'm trying this out on sublimeText3, but all the menu options (unityHelper) appear greyed out. Do you know what could be causing this?

    • Richie

      December 28, 2013 • Reply

      +1 for Sublime Text 3 support!!

    • Peter

      March 7, 2015 • Reply

      Here's how to do it on Sublime Text 3 (with Unity 5). Open Preferences (Edit>Preferences), then the External Tools tab. Select the sublimetext.exe as editor and for the Editor Args put: "$(File):$(Line)"

      You can checkout my tweet for an image illustrating the same: https://twitter.com/peteretelej/status/574130701391392768

  • shakac

    March 19, 2014 • Reply

    Excellent Excellent
    recently i have problem in my monodevelop it crushes when i open that i did not resolve that
    so i m searching a text editor for unity.your tutorial gave me so much help.
    thank you


Leave a Reply

Your email address will not be published. Required fields are marked *