はじめに
今回はDebug.Log
などのConsole
へのログ出力にハイパーリンクを埋め込む方法を紹介したいと思います。

やり方
外部サイト
// 外部サイトを開くハイパーリンク埋め込み Debug.Log("Website: <a href=\"https://www.hanachiru-blog.com/\">website</a> ");

Assets以下のファイル
// Assets/Scripts/Sample.csというスクリプトファイルの7行目を開くハイパーリンク埋め込み Debug.Log("Local File: <a href=\"Assets/Scripts/Sample.cs\" line=\"7\">local file</a>");

該当コード
// EditorGUI.cs private static void EditorGUI_OpenFileOnHyperLinkClicked(EditorWindow window, UnityEditor.HyperLinkClickedEventArgs args) { string path; if (!args.hyperLinkData.TryGetValue("href", out path)) return; string lineString; args.hyperLinkData.TryGetValue("line", out lineString); int line = -1; Int32.TryParse(lineString, out line); var sanitizedPath = path.Replace('\\', '/'); if (!String.IsNullOrEmpty(sanitizedPath)) { if (Uri.IsWellFormedUriString(sanitizedPath, UriKind.Absolute)) Application.OpenURL(path); else LogEntries.OpenFileOnSpecificLineAndColumn(path, line, -1); } }