- Home /
OpenFileAtLineExternal always opens file with MonoDevelop and never Visual Studio?
Greetings,
I have a filepath and a line number that I would like to open the file at in Visual Studio. I'm using OpenFileAtLineExternal
but it always seems to choose MonoDevelop over Visual Studio for some reason even though VS (Community 2015) is configured to be the editor of choice in the editor preferences/external tools.
Which is very weird because when I double click errors in the console it opens up with VS like it should.
I tried calling an internal function that sets VS as the active editor if it isn't already and then making the call to open the file, no dice:
var type = typeof(Editor).Assembly.GetType("UnityEditor.SyncVS");
var binding = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static;
var method = type.GetMethod("SetVisualStudioAsEditorIfNoEditorWasSet", binding);
method.Invoke(null, null);
I also tried AssetDatabase.OpenAsset
- which does seem to open with VS but it doesn't work quite well. The screen just flickers quickly to VS then back to Unity. As if I very quickly pressed Alt-Tab twice!
Thanks.
A workaround is to rename monodevelop.exe to something else. Still looking for the proper way to solve this.
Your answer
Follow this Question
Related Questions
Using custom external tools for custom assets? 0 Answers
Help with Missing Monobehaviours and Asset Serialization? 0 Answers
How do I return the path of a sub-asset in an AssetDatabase ? 0 Answers
Adding more image to detect but not updating application Arkit. 0 Answers
Unity 2019.4 Visual Studio not opening! 2 Answers