概要
Unityでコンソールウィンドウの行をダブルクリックしたときにコードにジャンプしますが それと同じことをUnityのインターナルなメソッドを呼ぶことでできるのでメモ
コード
static void OpenFileOnSpecificLineAndColumn(string filePath, int line, int column) { Assembly.GetAssembly(typeof(EditorApplication)) .GetType("UnityEditor.LogEntries") .GetMethod(nameof(OpenFileOnSpecificLineAndColumn), BindingFlags.Static | BindingFlags.Public) .Invoke(null, new object[] { filePath, line, column }); }
使用例
var path = AssetDatabase.GetAssetPath(アセット); var ioPath = Application.dataPath.Replace("Assets", "") + path; OpenFileOnSpecificLineAndColumn(ioPath, line, 0);
pathにはApplication.dataPath
とAssetDatabase.GetAssetPath
をくっつけたものを指定する。