Skip to content

Instantly share code, notes, and snippets.

@cyross
Last active September 25, 2019 10:09
Show Gist options
  • Select an option

  • Save cyross/9283469 to your computer and use it in GitHub Desktop.

Select an option

Save cyross/9283469 to your computer and use it in GitHub Desktop.
Unity+NGUIで、ラベルに描画した文字の最後尾の位置を取得
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