Unity3D---GUI
来源:互联网 发布:sql server 2008密钥 编辑:程序博客网 时间:2024/05/16 10:18
GUI
1、标签:
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 t, conte: Recnt : GUIContent, style : GUIStyle) : void
Rect:有四个参数x、y、wide、height
Text:显示在标签上的文本
Image:显示标签上的纹理
Style:使用样式
如:
public Texture2D img;
void OnGUI() {
GUI.Label(new Rect(10, 10, 100, 20), "Hello World!");
GUI.Label(new Rect(10,50,img.width,img.height),img);
}
2、盒子:
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
如:
public Texture2D img;
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 (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
如:
GUI.Button(new Rect(10, 80, 150, 20), new GUIContent("我有提示", "恭喜你中奖了!"));
// 在旁边的位置显示提示信息。
GUI.Label(new Rect(130, 40, 150, 40), GUI.tooltip);
//按钮上面有图片
GUI.Button(new Rect(10, 180, 150, 20), new GUIContent("我有提示", img));
4、重复按钮
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 (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="Hello World";
str = GUI.TextField(new Rect(10, 10, 200, 20), str);
str = GUI.TextField(new Rect(10, 10, 200, 20), str, 25);
6、密码文本:
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 str= "请输入密码:";
str= GUI.PasswordField(new Rect(10, 10, 200, 20), str, "*"[0]);
str= GUI.PasswordField(new Rect(10, 10, 200, 20), str, "*"[0],10);或
str= GUI.PasswordField(new Rect(10, 10, 200, 20), str, ‘*’,10);
7、文本域:
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);
8、Application事件
//跳转到登录视图
Application.LoadLevel("Login");
//跳转到本视图(游戏重新开始)
Application.LoadLevel(Application.loadedLevelName);
//退出游戏
Application.Quit();
9、字体设置
//设置字体大小
GUI.skin.label.fontSize=50;
//设置字体颜色
GUI.color = Color.red;
string aa = "我们都很好";
更多精彩请点击 http://www.gopedu.com/
1、标签:
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 t, conte: Recnt : GUIContent, style : GUIStyle) : void
Rect:有四个参数x、y、wide、height
Text:显示在标签上的文本
Image:显示标签上的纹理
Style:使用样式
如:
public Texture2D img;
void OnGUI() {
GUI.Label(new Rect(10, 10, 100, 20), "Hello World!");
GUI.Label(new Rect(10,50,img.width,img.height),img);
}
2、盒子:
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
如:
public Texture2D img;
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 (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
如:
GUI.Button(new Rect(10, 80, 150, 20), new GUIContent("我有提示", "恭喜你中奖了!"));
// 在旁边的位置显示提示信息。
GUI.Label(new Rect(130, 40, 150, 40), GUI.tooltip);
//按钮上面有图片
GUI.Button(new Rect(10, 180, 150, 20), new GUIContent("我有提示", img));
4、重复按钮
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 (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="Hello World";
str = GUI.TextField(new Rect(10, 10, 200, 20), str);
str = GUI.TextField(new Rect(10, 10, 200, 20), str, 25);
6、密码文本:
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 str= "请输入密码:";
str= GUI.PasswordField(new Rect(10, 10, 200, 20), str, "*"[0]);
str= GUI.PasswordField(new Rect(10, 10, 200, 20), str, "*"[0],10);或
str= GUI.PasswordField(new Rect(10, 10, 200, 20), str, ‘*’,10);
7、文本域:
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);
8、Application事件
//跳转到登录视图
Application.LoadLevel("Login");
//跳转到本视图(游戏重新开始)
Application.LoadLevel(Application.loadedLevelName);
//退出游戏
Application.Quit();
9、字体设置
//设置字体大小
GUI.skin.label.fontSize=50;
//设置字体颜色
GUI.color = Color.red;
string aa = "我们都很好";
更多精彩请点击 http://www.gopedu.com/
0 0
- Unity3D---GUI
- <Unity3D>Unity3D GUI控件
- Unity3D GUI类接口
- Unity3D GUI基础
- Unity3D GUI效果一览
- Unity3D GUI 效果一览
- Unity3d GUI思考
- Unity3D GUI 控件一览
- Unity3d gui自适应屏幕
- Unity3d gui自适应屏幕
- Unity3D-- GUI 时钟脚本
- Unity3D GUI TextField
- [Unity3D]GUI 效果一览
- Unity3d-GUI入门
- Unity3D GUI 拖动窗口
- Unity3d GUI适应分辨率
- Unity3d GUI 时钟脚本
- Unity3d GUI闪烁效果
- Shell按行读取文件的方法
- 寻找两个链表的交点
- 【USACO】namenum
- 高质量的C++编程指南总结(二):常量、函数设计
- 《设计模式之禅》——访问者模式
- Unity3D---GUI
- ioctl说明
- poj-1502 MPI Maelstrom
- 【转】C#如何读取txt文件中每一行每一个数据
- 【USACO】palsquare
- Android弹框当前位置
- scala:Array(100) 和 new Array(100)的区别
- 【USACO】dualpal
- 啊哈C——学习3.6一起来找茬