Quantcast
Channel: C#タグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 9525

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

$
0
0

TL;DR;

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

codelin.gif

ConsoleWindow以外で

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

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

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

Sample project

https://github.com/wallstudio/UnityTest_2019_4_4/blob/codelink/Assets/Editor/TestEditor.cs

参考

Unity-Technologies / UnityCsReference (github)


Viewing all articles
Browse latest Browse all 9525

Trending Articles