Hi! I’m developing an extension of Unity, but I’m having a problem.
I need to open any script (inside the editor) programatically, and that script should be openned in the mono/msvs project, exactly like when you double click a script.
I’ve tried using “EditorUtility.OpenWithDefaultApp(fileName);” but it opens the individual file, not inside the project.
AssetDatabase.OpenAsset() works for me, though I have to use MonoScript.FromMonoBehavior() or MonoScript.FromScriptableObject() to get an appropriate object to pass to OpenAsset(). Which means that I have to actually have an instance of the script available. I’ve tried to figure out how to go from script filename to a MonoScript instance, but I don’t recall having succeeded.
Hmm, a little bit of research suggests that AssetDatabase.LoadMainAssetFromPath() would also return a valid object to pass to OpenAsset(). So maybe try the following: