NGUI 会将空格自动换成换行符号, 这样就会使得我们想在一段文字的开头输入两个空格的时候出现问题.
找到NGUI 的NGUIText.cs脚本文件中的
ReplaceSpaceWithNewline
函数, 修改如下:
/// <summary>
/// Convenience function that ends the line by replacing a space with a newline character.
/// </summary>
[DebuggerHidden]
[DebuggerStepThrough]
static void ReplaceSpaceWithNewline (ref StringBuilder s)
{
//int i = s.Length - 1;
//if (i > 0 && IsSpace(s[i])) s[i] = '\n';
}
将该函数里面的内容注释掉就可以了.
测试结果
编辑器中的UILabel
游戏中的 UILabel
可以看到空格生效了