LoginSignup
1
0

More than 1 year has passed since last update.

UnityのDebug.Logでリッチテキストを有効にする

Last updated at Posted at 2022-09-13

躓いたのでメモ。(Unityは2021.3.5f1)

まずは結論から

この2行を Start() に追加すればOK!

void Start()
{
        GUIStyle style = new GUIStyle();
        style.richText = true;
}

これだけでリッチテキストが有効になるよ。やったね!

留意事項

  • デフォルトでは無効(style.richText = false)になってるらしい。(なんで!?)
  • 特にこだわりがなければ Start(){ ~ } の中に入れておけば良いと思う
  • どこか一つのスクリプト内で記述しておけば、他のスクリプトでもリッチテキストは有効になる
  • 一度有効にすれば、上で書いた2行を消しても有効になったままだよ
  • リッチテキストはtrue、falseで有効、無効にできる…と思ったのですが、やってみたら
    style.richText = false にしてもUnityを再起動してもリッチテキストは有効になったままになりました(何故…)

参考:リッチテキスト-Unityマニュアル

1
0
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
1
0