Unity之GUI基础
来源:互联网 发布:阿里云备案核实电话 编辑:程序博客网 时间:2024/05/02 11:56
GUI基础:
1、Label:(不带边框的)
Label (position : Rect, text : string) : void
Label (position : Rect, image : Texture) : void
Label (position : Rect, content : GUIContent) : void
Label (position : Rect, text : string, style : GUIStyle) : void
Label (position : Rect, image : Texture, style : GUIStyle) : void
Label (position : Rect, content : GUIContent, style : GUIStyle) : void
public Texture2D img;
void OnGUI() {
GUI.Label(new Rect(20,30,100,40),"Hello Word",style:"10");//字体
20:离界面最左边的距离
30:离界面最上边的距离
100:字体的长度
40:字体的高度
"Hello Word":要输入的内容
style:内容字体的长度
GUI.Label(new Rect(10,50,img.width,img.height),img);//图片
}
2、Box(带有边框的)
Box (position : Rect, text : string) : void
Box (position : Rect, image : Texture) : void
Box (position : Rect, content : GUIContent) : void
Box (position : Rect, text : string, style : GUIStyle) : void
Box (position : Rect, image : Texture, style : GUIStyle) : void
Box (position : Rect, content : GUIContent, style : GUIStyle) : void
void OnGUI() {
GUI.Box(new Rect(10, 10, 100, 20), "Hello World!");
GUI.Box(new Rect(10,50,img.width,img.height),img);
}
3、Button
Button (position : Rect, text : String) : bool
Button (position : Rect, image : Texture) : bool
Button (position : Rect, content : GUIContent) : bool
Button (position : Rect, text : String, style : GUIStyle) : bool
Button (position : Rect, image : Texture, style : GUIStyle) : bool
Button (position : Rect, content : GUIContent, style : GUIStyle) : bool
void OnGUI() {
GUI.Button(new Rect(10, 10, 100, 20), "Hello World!");
GUI.Button(new Rect(10, 50, img.width, img.height), img);
GUI.Button(new Rect(10, 80, 150, 20), new GUIContent("我有提示", "恭喜你中奖了!"));
// 在旁边的位置显示提示信息。
GUI.Button(new Rect(130, 40, 150, 40), GUI.tooltip);
//按钮上面有图片
GUI.Button(new Rect(10, 180, 150, 20), new GUIContent("我有提示", img));
4、RepeatButton
RepeatButton (position : Rect, text : String) : bool
RepeatButton (position : Rect, image : Texture) : bool
RepeatButton (position : Rect, content : GUIContent) : bool
RepeatButton (position : Rect, text : String, style : GUIStyle) : bool
RepeatButton (position : Rect, image : Texture, style : GUIStyle) : bool
RepeatButton (position : Rect, content : GUIContent, style : GUIStyle) : bool
GUI.RepeatButton(new Rect(10, 10, 100, 20), "Hello World!");
GUI.RepeatButton(new Rect(10, 50, img.width, img.height), img);
GUI.RepeatButton(new Rect(10, 80, 150, 20), new GUIContent("我有提示", "恭喜你中奖了!"));
// 在旁边的位置显示提示信息。
GUI.RepeatButton(new Rect(130, 40, 150, 40), GUI.tooltip);
GUI.RepeatButton(new Rect(10, 180, 150, 20), new GUIContent("我有提示", img));
5、TextField
TextField (position : Rect, text : String) : String
TextField (position : Rect, text : String, maxLength : int) : String
TextField (position : Rect, text : String, style : GUIStyle) : String
TextField (position : Rect, text : String, maxLength : int, style : GUIStyle) : String
string str = "请输入账号";
str = GUI.TextField(new Rect(10, 10, 200, 20), str,20);
6、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
"*"[0]等价于'*'
string str1 = "请输入密码";
str= GUI.PasswordField(new Rect(10, 10, 200, 20), str, "*"[0]);
str1 = GUI.PasswordField(new Rect(450, 100, 120, 20), str1, '*');
7、TextArea
TextArea (position : Rect, text : String) : String
TextArea (position : Rect, text : String, maxLength : int) : String
TextArea (position : Rect, text : String, style : GUIStyle) : String
TextArea (position : Rect, text : String, maxLength : int, style : GUIStyle) : String
string str = "aaaa\nbbbb";
str = GUI.TextArea(new Rect(10, 10, 200, 100), str);
str = GUI.TextArea(new Rect(10, 10, 200, 100), str, 200);
MicrosoftInternetExplorer402DocumentNotSpecified7.8 磅Normal0
1、Label:(不带边框的)
Label (position : Rect, text : string) : void
Label (position : Rect, image : Texture) : void
Label (position : Rect, content : GUIContent) : void
Label (position : Rect, text : string, style : GUIStyle) : void
Label (position : Rect, image : Texture, style : GUIStyle) : void
Label (position : Rect, content : GUIContent, style : GUIStyle) : void
public Texture2D img;
void OnGUI() {
GUI.Label(new Rect(20,30,100,40),"Hello Word",style:"10");//字体
20:离界面最左边的距离
30:离界面最上边的距离
100:字体的长度
40:字体的高度
"Hello Word":要输入的内容
style:内容字体的长度
GUI.Label(new Rect(10,50,img.width,img.height),img);//图片
}
2、Box(带有边框的)
Box (position : Rect, text : string) : void
Box (position : Rect, image : Texture) : void
Box (position : Rect, content : GUIContent) : void
Box (position : Rect, text : string, style : GUIStyle) : void
Box (position : Rect, image : Texture, style : GUIStyle) : void
Box (position : Rect, content : GUIContent, style : GUIStyle) : void
void OnGUI() {
GUI.Box(new Rect(10, 10, 100, 20), "Hello World!");
GUI.Box(new Rect(10,50,img.width,img.height),img);
}
3、Button
Button (position : Rect, text : String) : bool
Button (position : Rect, image : Texture) : bool
Button (position : Rect, content : GUIContent) : bool
Button (position : Rect, text : String, style : GUIStyle) : bool
Button (position : Rect, image : Texture, style : GUIStyle) : bool
Button (position : Rect, content : GUIContent, style : GUIStyle) : bool
void OnGUI() {
GUI.Button(new Rect(10, 10, 100, 20), "Hello World!");
GUI.Button(new Rect(10, 50, img.width, img.height), img);
GUI.Button(new Rect(10, 80, 150, 20), new GUIContent("我有提示", "恭喜你中奖了!"));
// 在旁边的位置显示提示信息。
GUI.Button(new Rect(130, 40, 150, 40), GUI.tooltip);
//按钮上面有图片
GUI.Button(new Rect(10, 180, 150, 20), new GUIContent("我有提示", img));
4、RepeatButton
RepeatButton (position : Rect, text : String) : bool
RepeatButton (position : Rect, image : Texture) : bool
RepeatButton (position : Rect, content : GUIContent) : bool
RepeatButton (position : Rect, text : String, style : GUIStyle) : bool
RepeatButton (position : Rect, image : Texture, style : GUIStyle) : bool
RepeatButton (position : Rect, content : GUIContent, style : GUIStyle) : bool
GUI.RepeatButton(new Rect(10, 10, 100, 20), "Hello World!");
GUI.RepeatButton(new Rect(10, 50, img.width, img.height), img);
GUI.RepeatButton(new Rect(10, 80, 150, 20), new GUIContent("我有提示", "恭喜你中奖了!"));
// 在旁边的位置显示提示信息。
GUI.RepeatButton(new Rect(130, 40, 150, 40), GUI.tooltip);
GUI.RepeatButton(new Rect(10, 180, 150, 20), new GUIContent("我有提示", img));
5、TextField
TextField (position : Rect, text : String) : String
TextField (position : Rect, text : String, maxLength : int) : String
TextField (position : Rect, text : String, style : GUIStyle) : String
TextField (position : Rect, text : String, maxLength : int, style : GUIStyle) : String
string str = "请输入账号";
str = GUI.TextField(new Rect(10, 10, 200, 20), str,20);
6、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
"*"[0]等价于'*'
string str1 = "请输入密码";
str= GUI.PasswordField(new Rect(10, 10, 200, 20), str, "*"[0]);
str1 = GUI.PasswordField(new Rect(450, 100, 120, 20), str1, '*');
7、TextArea
TextArea (position : Rect, text : String) : String
TextArea (position : Rect, text : String, maxLength : int) : String
TextArea (position : Rect, text : String, style : GUIStyle) : String
TextArea (position : Rect, text : String, maxLength : int, style : GUIStyle) : String
string str = "aaaa\nbbbb";
str = GUI.TextArea(new Rect(10, 10, 200, 100), str);
str = GUI.TextArea(new Rect(10, 10, 200, 100), str, 200);
MicrosoftInternetExplorer402DocumentNotSpecified7.8 磅Normal0
更多精彩关注:http://www.gopedu.com/
0 0
- unity之GUI基础
- Unity之GUI基础
- unity之GUI基础
- Unity学习之GUI基础
- unity之GUI基础(二)
- unity学习之GUI基础2
- 01.Unity GUI基础
- C#编写Unity基础GUI之按钮控件
- Unity学习之GUI
- Unity学习之GUI
- unity学习之GUI
- Unity之GUI复习
- Unity项目之GUI注册
- java基础之GUI
- java基础之GUI
- Java基础之GUI
- java基础之GUI
- unity基础开发----GUI实用代码
- 线性表笔记
- LeetCode[Math]: Excel Sheet Column Number
- 树的笔记
- cocos2dx 3.x 在wp开发时,使用sqlite3出现无法使用/ZW编译的问题
- unity3D—GUI基础
- Unity之GUI基础
- 二进制、八进制、十进制、十六进制之间转换
- 图及排序的笔记
- ubuntu右上角红色三角警告
- #include #import @class区别
- [转载]JAVA坏境变量设置与作用
- 详细解说STL hash_map系列
- Pascal's Triangle II
- navicat for mysql linux 破解方法