2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

UnityのTextで禁則処理する

Posted at

TextMeshProを使っていない現場だってあるんですよ!

作ったもの

HyphenationJpn_uGUI compatible with Unity2022

インストール

  1. Open Package Manager
  2. Click Add package from git URL...
  3. Add the uri: https://github.com/izugch73/HyphenationJpn_uGUI.git?path=Assets/Plugins/HyphenationJpn

お好みで#0.1.1とか。
Readme.mdに書いてどうぞ...

使い方

サンプルシーンそのまま置いてますが、TextのあるところにHypenationJpnを置いて、SetTextすると動作すると思います。

Fork元

テラシュールブログの椿さんが10年前に作ったTextの禁則処理をUnity2022.3で動くようにしたものです。偉大な先人に感謝。。。

マイグレーション内容

GetText -> SetText

なぜかセッターの名前がGetTextだったのをSetTextに修正(偉大な先人であるため、私が知らない謎の理由があるのかもしれない。畏れ多くもメソッド名を変更)

HyphenationJpn.cs
	public void SetText(string str)
	{
		text = str;
		UpdateText(text);
	}

OnValidate

OnValidateはエディタでしか動作しない

HyphenationJpn.cs
#if UNITY_EDITOR
        protected override void OnValidate()
        {
            base.OnValidate();
            UpdateText(text);
        }
#endif

PRの吸収

その他

  • asmdef
  • package化
  • サンプル更新

TextMeshProをご利用の方

https://nekojara.city/unity-textmesh-pro-line-breaking

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?