- Home /
How to open file in MonoDevelop by script?
Hello, I am making a custom script template. I want this template to be in menu Assets/Create/CustomTemplate. I created corresponding menu item, and I want to open my previously saved text file (Editor\Data\Resources\ScriptTemplates\CustomTemplate.cs) in default script editor. My question is - is there any way that i can get default script editor via script and give it a path of a file to open?
I am aware that this can be done via System.Diagnostics.Process.Start(), but this will open hardcoded application, not the default script editor. I've searched alot, and the only things I've found is
UnityEditorInternal.InternalEditorUtility.OpenFileAtLineExternal();
and
AssetDatabase.OpenAsset();
I think the first one pretty close, but I don't know how I get correct name of the script
Answer by artman_12 · Feb 26, 2013 at 02:29 PM
I've found out myself, It's possible to use
UnityEditorInternal.InternalEditorUtility.OpenFileAtLineExternal(@"C:\1.txt", 1);
It wasn't obvious for me that OpenFileAtLineExternal() takes a path, as "filename"
Thanks, this proved to be vastly easier than trying to launch $$anonymous$$onoDevelop as a process correctly on multiple different platforms!
I haven't been able to open a file not situated in Assets.
Your answer

Follow this Question
Related Questions
Is it possible to detect changes to a different component within an editor script? 0 Answers
How do I create a new object in the Editor as a child of another object? 1 Answer
Get CustomEditor for Script 0 Answers
Editor Scripting Question 1 Answer
can't dynamically add scripts to gameObjects via Editor 0 Answers