This seems similar to
Monodevelopment fails to open scripts directly from Unity - Unity Engine - Unity Discussions
but I am using native Ubuntu (not Gnome).
When I open a C# from Unity it launches Monodevelop but it is as if it never gets passed the file argument and it just opens as if I launched it normally. Then I have to open the file manually in Monodevelop.
I have tried to use the monodevelop (builtin) as well as install monodevelop from the repo and no go.
Interestingly, if I run monodevelop (from the repo) on the command line and pass a file argument I experience the same behavior.
So Monodevelop standalong (non Unity) is actually working from the command line. Not sure why it wasn’t working before.
After updating to latest build (5.2) the internal editor doesn’t launch anymore but Monodevelop standalone does. It still doesn’t open the files though.
The link above says that the “External Script Editor Args” option is Windows only but I feel like that is the issue. I also use Fish and think that may also be the case. I did try switching my default shell back to bash with
chsh
but no go.
Just talking outloud here. Really want to get this working.
Ahh, I just installed Visual Studio Code for linux and it doesn’t work either but it leaves a hint behind.
It says the file name it is opening is
QuitApplicationScript.cs" /home/elijah/projects/unity/New Unity/ Project/"/home/elijah/projects/unity/New Unity Project/Assets/Scripts
Notice the " in the path and the duplication of the path.
See screenshot for exact formatting.
Okay, it works with Visual Studio Code if I change the “windows only” External Script Editor Args from "
(File)" to
(File). However, $(File) does not work with monodevelop so VSC will have to be it for now.
This is using Fish if it matters.
Having the same issues, MonoDevelop(Bulit-In) doesn’t work, but /usr/bin/monodevelop doesn’t open files. If you run
man monodevelop
you’ll see that it doesn’t take a file as an argument. However, you
can
run the prepackaged monodevelop from its location (e.g. /opt/Unity/MonoDevelop/bin/monodevelop) and it will run with a ($File) arguement.
The only problem I’m having now is the errors coming up in the prepackaged monodevelop when closing files:
System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
at System.ThrowHelper.ThrowInvalidOperationException (ExceptionResource resource) [0x00000] in /var/tmp/portage/dev-lang/mono-4.0.3.20/work/mono-4.0.3/external/referencesource/mscorlib/system/throwhelper.cs:94
at System.Collections.Generic.List
1[Mono.TextEditor.TextEditor+EditorContainerChild].ForEach (System.Action
1 action) [0x0006d] in /var/tmp/portage/dev-lang/mono-4.0.3.20/work/mono-4.0.3/external/referencesource/mscorlib/system/collections/generic/list.cs:597
at Mono.TextEditor.TextEditor.ForAll (Boolean include_internals, Gtk.Callback callback) [0x0000d] in /home/builduser/buildslave/monodevelop/build/monodevelop/main/src/core/Mono.Texteditor/Mono.TextEditor/Gui/TextEditor.cs:248
at Gtk.Container.Forall_cb (IntPtr container, Boolean include_internals, IntPtr cb, IntPtr data) [0x00031] in /var/tmp/portage/dev-dotnet/gtk-sharp-2.12.21/work/gtk-sharp-2.12.21/gtk/generated/Container.custom:168
same i cant open files with mono and if i manual it i get errors
is ther some Notpade(text editor) that has c# sytax and meybe possiblity to have suggestion implementation so i can exaple add all unity comands to suggestions so when i thy Phy it offers me Physics
or any workable suggestion or am i doomed and must swich back to ubuntu
I think on Fedora it has somthing to do with newer mono or somthing
This seems similar to
Monodevelopment fails to open scripts directly from Unity - Unity Engine - Unity Discussions
but I am using native Ubuntu (not Gnome).
When I open a C# from Unity it launches Monodevelop but it is as if it never gets passed the file argument and it just opens as if I launched it normally. Then I have to open the file manually in Monodevelop.
I have tried to use the monodevelop (builtin) as well as install monodevelop from the repo and no go.
Interestingly, if I run monodevelop (from the repo) on the command line and pass a file argument I experience the same behavior.
I was pissed off with same problem. I tried to search but didn’t find anything on forumes. So I turned to visual studio…
VS is very easy to integrate with unity and works as good as monodevelop.
here is how to integrate VS with unity:-
#STEP
1
install VS and install the
Legacy C# Support
extension(by From within Visual Studio Code, you can use
Quick Open
(Ctrl+P) and paste “ext install omnisharp” then press Enter.)
If you have it and you are using the preview
C# extension
, please uninstall it and install the
Legacy C# Support
extension.(by From within Visual Studio Code, you can use
Quick Open
(Ctrl+P) and paste “ext install omnisharp” then press Enter.)
#STEP
2
Clone the VScode from here-
GitHub - dotBunny/VSCode: Unity Visual Studio Code Integration
Open up a console and do a clone of the repo to get the plug-in source code.
git clone
GitHub - dotBunny/VSCode: Unity Visual Studio Code Integration
#STEP
3
Extract the VScode and put it in your unity project under Assets/Plugins/Editor/ directory.
It is important to make sure that the VSCode.cs file is placed under an Editor folder in the project. An example of this arrangement would be placing the file in /Assets/Plugins/Editor/VSCode.cs
and install required debugger and tools extension by unity from VS
and ENJOY GAME MAKING…
The problem is that Unity attempts to open the monodevelop with an invalid argument.
The first argument it uses is “–nologo” which is deprecated in monodevelop but safely ignored anyway
The second argument is the sln file which works fine
The third argument is the filename + line number in this format ;<#> which would also work fine if not for the fact that Unity sends line number “-1” which being an invalid line number causes monodevelop to reject the argument entirely. Unity should be opening with line zero if there’s no specific line number so this is a bug. I wrote a short bash script that you can inline to work around the problem:
#!/bin/bash
nologo=“$1”
sln=“$2”
fileLine=“$3”
file=
echo "$fileLine" | cut -d';' -f1
line=
echo "$fileLine" | cut -d';' -f2
if [ $line = “-1” ]; then
line=0
monodevelop “$sln” “$file;$line”
Save the above script as “monodevelop” in your home directory and set it as executable. In Unity Edit->Preferences->External Tools->External_Script_Editor select it by using the “Browse…” option in the drop down. Unity will read the file’s name and “think” the file is the actual monodevelop binary and snap the selection back to “monodevelop” only it will now work like it’s supposed to.

ferreusveritas:
The problem is that Unity attempts to open the monodevelop with an invalid argument.
The first argument it uses is “–nologo” which is deprecated in monodevelop but safely ignored anyway
The second argument is the sln file which works fine
The third argument is the filename + line number in this format ;<#> which would also work fine if not for the fact that Unity sends line number “-1” which being an invalid line number causes monodevelop to reject the argument entirely. Unity should be opening with line zero if there’s no specific line number so this is a bug. I wrote a short bash script that you can inline to work around the problem:
#!/bin/bash
nologo=“$1”
sln=“$2”
fileLine=“$3”
file=
echo "$fileLine" | cut -d';' -f1
line=
echo "$fileLine" | cut -d';' -f2
if [ $line = “-1” ]; then
line=0
monodevelop “$sln” “$file;$line”
Save the above script as “monodevelop” in your home directory and set it as executable. In Unity Edit->Preferences->External Tools->External_Script_Editor select it by using the “Browse…” option in the drop down. Unity will read the file’s name and “think” the file is the actual monodevelop binary and snap the selection back to “monodevelop” only it will now work like it’s supposed to.
Dude! You’re a genius. I just tried it out and works well. Other than it still opens it up in a new window each time rather than opening a tab within already open sln.
Thanks
@ferreusveritas
I played around with the bash a little, tried to find a way to attach same process id to it.
I wanted to try connect process manually through the script, ended up failing and overwrote solution parameter. (Uhm… I tried to kill the process and open new one at this point
)
I noticed that without solution, window would keep opening file tabs. So the process is already linked…
Then I though how about just open a solution, and if it’s open, dont mention the solution.
The result, it works! At least for me, need additional testers.
#!/bin/bash
#ferreusveritas code
nologo="$1"
sln=`echo "$2"`
fileLine="$3"
file=`echo "$fileLine" | cut -d';' -f1`
line=`echo "$fileLine" | cut -d';' -f2`
if [ $line = "-1" ]; then
line=0
#Advis code
PID=`ps aux | grep "/usr/bin/monodevelop" | grep "bash"`
if [[ "" != $PID ]]; then
monodevelop "$file;$line"
monodevelop "$sln" "$file;$line"
Mentioned thread in Running monodevelop from linux terminal (ubuntu 17.10) always opens a new instance. · Issue #4649 · mono/monodevelop · GitHub
Tried checking solution name, which will now open a new solution if you use multiple Unity editors.
However, when you try to open a file from older solution through editor, it will send it to the newer window.
The process is attached to newer window and doesn’t renew back to old window as monodevelop seems to forget it had an open window for the solution.
#!/bin/bash
#ferreusveritas code
nologo="$1"
sln=`echo "$2"`
fileLine="$3"
file=`echo "$fileLine" | cut -d';' -f1`
line=`echo "$fileLine" | cut -d';' -f2`
if [ $line = "-1" ]; then
line=0
#Advis code
PID=`ps aux | grep "/usr/bin/monodevelop" | grep "$sln"`
if [[ "" != $PID ]]; then
monodevelop "$file;$line"
monodevelop "$sln" "$file;$line"
Seem to work and open solutions in 2018.3.3f1 and 2019.2.0a4 versions.
Older versions of Linux editor doesn’t open solution correctly in 2018.3.2f1 for my current monodevelop version(7.7 build 1869).
Edit:
Updated code in Monodevelop not opening files
Advis91:
Tried checking solution name, which will now open a new solution if you use multiple Unity editors.
However, when you try to open a file from older solution through editor, it will send it to the newer window.
The process is attached to newer window and doesn’t renew back to old window as monodevelop seems to forget it had an open window for the solution.
#!/bin/bash
#ferreusveritas code
nologo="$1"
sln=`echo "$2"`
fileLine="$3"
file=`echo "$fileLine" | cut -d';' -f1`
line=`echo "$fileLine" | cut -d';' -f2`
if [ $line = "-1" ]; then
line=0
#Advis code
PID=`ps aux | grep "/usr/bin/monodevelop" | grep "$sln"`
if [[ "" != $PID ]]; then
monodevelop "$file;$line"
monodevelop "$sln" "$file;$line"
Seem to work and open solutions in 2018.3.3f1 and 2019.2.0a4 versions.
Older versions of Linux editor doesn’t open solution correctly in 2018.3.2f1 for my current monodevelop version(7.7 build 1869).
Hey tried out your scripts and it works well with both my projects in Unity 2018.3.0f2 and 2018.3.6f1. Thanks heaps. Will try give Monodevelop a second change.
I do still get Monodevelop freezing on me randomly however. Even xKill wont work. But at least I can open scripts within the same project now 
Advis91:
Tried checking solution name, which will now open a new solution if you use multiple Unity editors.
1869).
you sir are a legend 
really glad to be able to have a stable editor, that actually works and feels nice.
since we’re talking about mono develop, has any of you guys, managed to get monodevelop “reading” code from other packages?
example: Cinemachine or photon.
for some reason, despite having the references added, but MonoDevelop does not appear to recognize code from these packages, which i assume is because they’re code is in DLL format?
Hmm… dont have any imported dlls to check that…
I wonder if other configs might get it to work.
But I improved my bash script.
It will now open solution only once.
Then it opens new files in monodevelop if have to.
I noticed some minor things after modifying the file.
I noticed these scripts stay as “zombie” processes (status) until Linux editor is closed. It just takes some more ram out of your system. The reason for it might be that Unity is just fine what it gets there and exits the main ide attach process and uses some other way to keep the connection (I think visual studio supports something like that).
Testing “zombie” status processes:
Open file from unity, first process stays sleeping, next one zombifies. First one zombifies when you close monodevelop.
2, Process name and command sometimes trunctuates.
If you wait for monodevelop to load the file, next time you open a new file process name and command might be trunctuated.
Unity opens the ide and script waits for monodevelop to close and then it just zombifies. Next processes will all just zombifie if ide is still open.
If you wait monodevelop to open the file, it shows up the first process in the list and the full command, but the next is most of the time trunctuated as the process to open the file happens too fast.
I presume it depends on your pc then where it trunctuates.
But now monodevelop should work a lot better!
#!/bin/bash
#ferreusveritas code
nologo="$1"
sln=`echo "$2"`
fileLine="$3"
file=`echo "$fileLine" | cut -d';' -f1`
line=`echo "$fileLine" | cut -d';' -f2`
if [ $line = "-1" ]; then
line=0
#Advis code
PID=`ps aux | grep "/usr/bin/monodevelop" | grep "$sln"`
if [[ "" == $PID ]]; then
exec -a "Monodevelop Unity" `monodevelop "$sln" "$file;$line"`
exec -a "Monodevelop Unity" `monodevelop "$file;$line"`
Edit:
Fixed some typos and removed unnessessary comments from script…
The fix was… exec
, but I kept exec -a "Monodevelop Unity"
if the process shows up in a process list at some point so I can see it better.