【Unity】Consoleのログにファイルへのリンクを埋め込む


TL;DR;

Debug.Log($@"<a href=""{filePath}"" line=""{line}"">link</a>");

ConsoleWindow以外で

UnityEditorInternal.InternalEditorUtility.OpenFileAtLineExternalで即時開くことができます。
Button等で蹴ってあげればいいでしょう。

また、ConsoleWindowと同じようにAタグによってリンクを張ることもできます。ただし、GUIStyleをCN Messageにしておく必要があります。

static Lazy<GUIStyle> STYLE = new Lazy<GUIStyle>(() => (GUIStyle)"CN Message");
EditorGUILayout.SelectableLabel($@"<a href=""{filePath}"" line=""{line}"">link</a>", STYLE.Value);

Sample project

参考

Unity-Technologies / UnityCsReference (github)