- Home /
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
Answer by Zv_oDD · Mar 02, 2014 at 09:54 PM
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.
Awesome, this must be a new feature since I posted my answer. Good to know, thanks for pointing it out!
Answer by yoyo · Dec 13, 2012 at 04:30 PM
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! :-)
Thank you But, I already tried to pass the script like done in notepad. I can use command prompt to pass the script and open in the text editor. It works fine. But, It does not opens up when i set the new editor in the unity and then double click the script from unity. Are there any other methods unity opens up a script file in a selected code editor?
Sorry, maybe I misunderstood your question. In the External Tools dialog you can click on the External Editor drop-down, select Browse ..., and then choose the executable you want to use for editing scripts (for example, on a Windows PC, "C:\Windows\system32\notepad.exe"). Once you select the external editor, then when you double-click on a script file it should open in the selected editor. Is that what you tried? Are you on PC or $$anonymous$$ac?
I'm on PC. Actually I'm creating a script editor for unity that i want to open the script directly from unity by double clicking the script just like opening in Visual Studio, $$anonymous$$onodevelop or notepad. I want to know how to pass the file to my editor. Is it the file path or something else? I already tried the file path. But, Not working. Any other way?
Your answer
Follow this Question
Related Questions
Why Preferences get lost after I close Unity? 0 Answers
How can i change the unit grid to pixel grid ? 0 Answers
How can I use VSCode as a diff/merge tool for Unity Collaborate? 1 Answer
Error in Console, for Editor Settings, don't understand how to fix 1 Answer
Why does my Skybox appear to be a very different color than what should be default? 1 Answer