Last active
August 3, 2018 23:18
-
-
Save sassembla/a51fc0d85672e2f3233607c9e0b6cac6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TMProのコンポーネント TMPro.TextMeshProUGUI textComponentというのがあったとして | |
textComponent.text = text; | |
// textComponentに対してwidthをセットする必要がある。高さは無限設定でOK | |
textComponent.rectTransform.sizeDelta = new Vector2(viewWidth, float.PositiveInfinity); | |
// このメソッドは、コンポーネントがgameobjectにアタッチされて、かつgameobjectがcanvasに乗っている場合のみ動作する。 | |
var textInfos = textComponent.GetTextInfo(text); | |
// 各行の要素とパラメータを取得する。 | |
var tmGeneratorLines = textInfos.lineInfo; | |
var lineSpacing = textComponent.lineSpacing; | |
var tmLineCount = textInfos.lineCount; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
それに対して、uGUIは
https://gist.github.com/sassembla/dd9a5de1826aa190ff583164fe9c537c