private string GetFormattedText(UnityEngine.UI.Text label, string msg) { if (msg.IsNullOrEmpty()) { return(string.Empty); } Rect rect = this.RectTransform.get_rect(); float width = ((Rect) ref rect).get_width(); float spaceWidth = this.GetSpaceWidth(label); label.set_horizontalOverflow((HorizontalWrapMode)1); StringBuilder stringBuilder = new StringBuilder(); int num1 = 0; float num2 = 0.0f; string str = "\n"; bool flag1 = Hyphenation.ExistsBehindHyphenation(msg[0]); bool flag2 = false; foreach (string word in this.GetWordList(msg)) { float num3 = this.GetTextWidth(label, word); num2 += width; if (word == str) { num2 = 0.0f + spaceWidth * 2f; ++num1; } else { if (word == string.Empty) { num2 += spaceWidth; } if (flag1) { if (!flag2) { flag2 = this.IsLineCountOver(label, num1 - 1); } if (flag2) { num3 = 0.0f; } if ((double)num2 > (double)width - (double)num3) { stringBuilder.Append(str); stringBuilder.Append(" "); num2 = this.GetTextWidth(label, word) + spaceWidth * 2f; ++num1; } } else if ((double)num2 > (double)width) { stringBuilder.Append(str); num2 = this.GetTextWidth(label, word); ++num1; } } stringBuilder.Append(word); } return(stringBuilder.ToString()); }