/// <summary> /// Process the raw text, called when something changes. /// </summary> void ProcessText() { mChanged = true; hasChanged = false; mLastText = mText; mProcessedText = mText.Replace("\\n", "\n"); if (mPassword) { string hidden = ""; if (mShowLastChar) { for (int i = 0, imax = mProcessedText.Length - 1; i < imax; ++i) { hidden += "*"; } if (mProcessedText.Length > 0) { hidden += mProcessedText[mProcessedText.Length - 1]; } } else { for (int i = 0, imax = mProcessedText.Length; i < imax; ++i) { hidden += "*"; } } mProcessedText = mFont.WrapText(hidden, mMaxLineWidth / cachedTransform.localScale.x, mMaxLineCount, false, NGUIFont.SymbolStyle.None); } else if (!mShrinkToFit) { if (mMaxLineWidth > 0) { mProcessedText = mFont.WrapText(mProcessedText, mMaxLineWidth / cachedTransform.localScale.x, mMaxLineCount, mEncoding, mSymbols); } else if (mMaxLineCount > 0) { mProcessedText = mFont.WrapText(mProcessedText, 100000f, mMaxLineCount, mEncoding, mSymbols); } } float scale = Mathf.Abs(cachedTransform.localScale.x); mSize = !string.IsNullOrEmpty(mProcessedText) ? mFont.CalculatePrintedSize(mProcessedText, mEncoding, mSymbols) : Vector2.one; mOriLinewidth = mSize.x; if (mShrinkToFit && mMaxLineWidth > 0) { // We want to shrink the label (when it doesn't fit) if (scale > 0f) { float maxSize = (float)mMaxLineWidth / mFont.size; scale = (mSize.x > maxSize) ? (maxSize / mSize.x) * mFont.size : mFont.size; cachedTransform.localScale = new Vector3(scale, scale, 1f); } else { mSize.x = 1f; cachedTransform.localScale = new Vector3(mFont.size, mFont.size, 1f); } } else { mSize.x = Mathf.Max(mSize.x, (scale > 0f) ? lineWidth / scale : 1f); } mSize.y = Mathf.Max(mSize.y, 1f); }