We need to precalculate size of Dimensions in UILable using that code:
void CalculateSizeText(string mText)
{
const int minWidth = 300;
const int minHeight = 1;
string mProcessedText;
NGUIText.rectWidth = 700;
NGUIText.rectHeight = 1000000;
NGUIText.WrapText(mText, out mProcessedText, true);
int mPrintedSize = SeatOnTableBtn.GetComponentInChildren<UILabel>().fontSize;
NGUIText.fontSize = mPrintedSize;
Vector2 mCalculatedSize = Vector2.zero;
mCalculatedSize = NGUIText.CalculatePrintedSize(mProcessedText);
int Width = Mathf.Min(minWidth, Mathf.RoundToInt(mCalculatedSize.x));
int Height = Mathf.Max(minHeight, Mathf.RoundToInt(mCalculatedSize.y));
Debug.Log("Width=" + Width);
Debug.Log("Height=" + Height);
}
But we couldn't get the expected result: on the test string function returned those values: Width = 300, Height = 22.
If we put this string to the UILable (parameer overflow is set to ResizeHeight), we get Dimensions = 300x66.
Could you please tell me how to calculate Dimensions in UILable correctly? Thanks!