External Script Editor

Does anyone know how the external script editor reads the code file from unity with a single click?

I mean when we press Edit->Preferences->External Tools->External Script Editor.

It would be really helpful for me. Thank you

The External Editor is called via the Operating System’s shell ( at least for unsupported ones, ie not Visual Studio)

The External Script Editor Args option allows you to specify the command line parameters passed to the external editor.
There are a few variables you can use in this options to set the file name and line number:

  • $(File) is replaces with the File
    Name
  • $(Line) is replaced with the Line
    Number

So if your external editor has a command line argument syntax that support those parameters you can add them in.
For example suppose an editor that uses -f for file name and -n for line number you could write the External Script Editor Args option as:

-f "($File)" -n $(Line)

So the final system/shell call coming from Unity might look like

"C:\Program Files\SomeTextEditor\editor.exe" -f "C:\Project\Scripts\script.cs" -n 0

Exactly the same way you can call that script editor on the command line.

Unity will launch the external script editor and pass the full path to the script file as an argument on the command line. So for example if you select Windows notepad.exe as your script editor, then when you edit MyScript.cs, Unity will run something like:

C:/Windows/system32/notepad.exe “C:/Users/bob/unityprojects/myproject/Assets/MyScript.cs”

Similar story on a Mac – the path to the script is passed as a command line argument to the editor.

Unfortunately external script editors cannot be configured to jump to a line number when you double-click on the console log, Unity just doesn’t pass them that information. If you want this functionality, it is possible, but messy – you can replace the standard MonoDevelop.exe with a launch program that reads the MonoDevelop command line (which includes line number information) and then launches the editor of your choice, reformatting the command line parameters as needed. (I know it’s possible because I’ve done it, but that doesn’t mean I necessarily recommend it! :slight_smile: