2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

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

Posted at

TL;DR;

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

codelin.gif

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)

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?