Last active
September 25, 2019 10:09
-
-
Save cyross/9283469 to your computer and use it in GitHub Desktop.
Unity+NGUIで、ラベルに描画した文字の最後尾の位置を取得
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
| public class Hoge : MonoBehavior { | |
| private float x; | |
| private float y; | |
| private void GetPos(){ | |
| string eol; | |
| // 禁則処理によって改行された部分に改行文字が挿入される | |
| if(!NGUIText.WrapText(area.text, out eol)){ eol = area.text; } | |
| // 最後の行を取得して、その行の描画サイズを取得 | |
| string[] lines = eol.Split(cr_char); | |
| Vector2 vec = NGUIText.CalculatePrintedSize(lines[lines.Length-1]); | |
| x = vec.x; | |
| y = vec.y; | |
| return; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment