纳金网

标题: 给TextField自定义属性后,它变成能换行输入的了?怎么设置成让它不能换行呢? [打印本页]

作者: 她。    时间: 2013-1-16 08:32
标题: 给TextField自定义属性后,它变成能换行输入的了?怎么设置成让它不能换行呢?
/*CommonTextField.cs*/using UnityEngine;
using System.Collections;public class CommonTextField : MonoBehaviour {

//单行文本框的风格对象
public static GUIStyle style;

//单行文本框的宽度和高度
public static int width = 100;
public static int height = 40;

//初始化
void Start () {
  style = new GUIStyle();

  //设置未选中情况下背景图片和标题文本颜色
  style.normal.background = (Texture2D)Resources.LoadAssetAtPath("Assets/CustomGUI/Texture/textbackground.png", typeof(Texture2D));  style.normal.textColor = Color.white;

  //设置选中情况下背景图片和标题文本颜色
  style.hover.background = (Texture2D)Resources.LoadAssetAtPath("Assets/CustomGUI/Texture/textbackground.png", typeof(Texture2D));  style.hover.textColor = Color.white;

  //设置文本位置为居中左对齐
  style.alignment = TextAnchor.MiddleLeft;
  
  //载入字体、设置字体大小
  style.font = CommonFont.LoadFont();
  style.fontSize = 22;
}
}  
作者: 狂风大尉    时间: 2013-1-29 17:53
希望更多的朋友分享制作经验





欢迎光临 纳金网 (http://go.narkii.com/club/) Powered by Discuz! X2.5