這裏有很多U3D資源、U3D培訓視頻、U3D教程、U3D常見問題、U3D項目源碼,我們致力於打造業內unity3d培訓、學習第一品牌
1、Label
void OnGUI() {
//static function Label (position : Rect, text : string) : void
E.g: GUI.Label(Rect(10, 10, 100, 20), "Hello World!");
//static function Label (position : Rect, image : Texture) : void
E.g: GUI.Label(new Rect (20,50,img.width ,img.height),img);
//static function Label (position : Rect, content : GUIContent) : void
E.g: GUI.Label(new Rect(10, 80, 150, 20), new GUIContent("請點這裏", "content "));
GUI.Label(new Rect(130, 40, 150, 40), GUI.tooltip);
//static function Label (position : Rect, text : string, style : GUIStyle) : void
和第一個相差不多,就是多加了個style限制字數。
E.g GUI.Label(new Rect(10, 10, 100, 20), "Hello World!",style:"3");
}
2、Box、Button和Label用法差不噢多,就是Botton是一個按鈕,Label是個文本格式,Box是個盒子
3、RepeatButton和Button基本一樣,Botton是點擊一下的控件,而RepeatButton是雙擊的控件
4、TextField:文本字段
能夠往裏面輸入和消除文本,而且這個減少了圖片和觸碰效果,增加了限制字數
//static function TextField (position : Rect, text : String, maxLength : int) : String
E.g public string stringToEdit = "Hello World";
void OnGUI()
{
stringToEdit = GUI.TextField(new Rect(10, 10, 200, 20), stringToEdit, 25);
}
5、PasswordField:密碼字段
PasswordField (position : Rect, password : String, maskChar : char) : String
PasswordField (position : Rect, password : String, maskChar : char, maxLength : int) : String
PasswordField (position : Rect, password : String, maskChar : char, style : GUIStyle) : String
PasswordField (position : Rect, password : String, maskChar : char, maxLength : int, style : GUIStyle) : String
注:String:maskChar----用於密碼的字符遮罩。
E.g public string stringToEdit = "Hello World";
void OnGUI()
{
stringToEdit = GUI.PasswordField(new Rect(10, 10, 200, 20), stringToEdit, "*"[0], 25);
}
文本可消除
6、TextArea:文本區域
用法和TextField用法差不多,就是可以輸入多行
E.g public string stringToEdit = "Hello World\nI've got 2 lines...";
void OnGUI()
{
stringToEdit = GUI.TextArea(new Rect(10, 10, 200, 100), stringToEdit, 200);
}