码迷,mamicode.com
首页 > 编程语言 > 详细

Unity3D之UILabel的属性设置

时间:2015-02-26 13:31:46      阅读:497      评论:0      收藏:0      [点我收藏+]

标签:unity3d   uilabel   

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;
	}
}
技术分享




Unity3D之UILabel的属性设置

标签:unity3d   uilabel   

原文地址:http://blog.csdn.net/yuxikuo_1/article/details/43951771

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!