1、设置字数限制,超出部分用省略号代替
添加UILabel的NGUI控件,给控件绑定脚本,如下:
using UnityEngine; using System.Collections; public class LabelScript : MonoBehaviour { private UILabel label; // Use this for initialization void Start () { label = this.GetComponent<UILabel>(); } // Update is called once per frame void Update () { string txt="北京市海淀区"; if(txt.Length>5) { txt=txt.Substring(0,5)+"..."; } label.text = txt; } }
时间: 2024-11-14 11:20:31