Exemple #1
0
    /// <summary>
    /// Process the raw text, called when something changes.
    /// </summary>

    void ProcessText()
    {
        mChanged   = true;
        hasChanged = false;
        mLastText  = mText;

        mProcessedText = mText;
        if (TranslateReturn)
        {
            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, UIFont.SymbolStyle.None);
        }
        else if (mMaxLineWidth > 0)
        {
            mProcessedText = mFont.EmojiWrapText(mProcessedText, mMaxLineWidth / cachedTransform.localScale.x, mMaxLineCount, mEncoding, mSymbols, mSpacingX, EmojiMap);
        }
        else if (mMaxLineCount > 0)
        {
            mProcessedText = mFont.EmojiWrapText(mProcessedText, 100000f, mMaxLineCount, mEncoding, mSymbols, mSpacingX, EmojiMap);
        }
        mSize = !string.IsNullOrEmpty(mProcessedText) ? mFont.EmojiCalculatePrintedSize(mProcessedText, mEncoding, mSymbols, mSpacingX, mSpacingY, TranslateReturn, EmojiMap) : Vector2.one;
        float scale = cachedTransform.localScale.x;

        mSize.x = Mathf.Max(mSize.x, (mFont != null && scale > 1f) ? lineWidth / scale : 1f);
        mSize.y = Mathf.Max(mSize.y, 1f);
    }