在UGUI里Text显示的字符有时候需要个数限制。只需将下面代码绑定到text上就可以了。
namelenth是用来接收文字个数的。在其他脚本里只要设置namelenth这个值就可以。由于Setnamelength()这个方法一直在Update里被调用,所以可以实时的将改变的个数值namelenth传入下面的Setnamelength()这个方法。
本案例中用按键盘P键来限定了传入个数为3。
代码如下:
测试效果如下:
在UGUI里Text显示的字符有时候需要个数限制。只需将下面代码绑定到text上就可以了。
namelenth是用来接收文字个数的。在其他脚本里只要设置namelenth这个值就可以。由于Setnamelength()这个方法一直在Update里被调用,所以可以实时的将改变的个数值namelenth传入下面的Setnamelength()这个方法。
本案例中用按键盘P键来限定了传入个数为3。
代码如下:
测试效果如下:
UGUI与以往的NGUI不同之处很多其中一大特点就是UGUI 把精灵图集的功能取消了。首先是我们看看UGUI的UI界面:其中有项是
DATALENGTH返回任何表达式所占用的字节数。语法DATALENGTH ( expression ) 参数expressio
举报文章
请选择举报类型
补充说明
0/200
上传截图
格式支持JPEG/PNG/JPG,图片不超过1.9M