Unity3D---GUI
2015-01-29 20:25
239 查看
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/
相关文章推荐
- [Unity3D]使用OnGUI函数显示状态栏并且使用触发器修改玩家当前信息
- [Unity3D]手机3D游戏开发:如何实现最高分的存储与显示(二)----使用GUI.Box显示文字
- Unity3D笔记(二)使用GUI做井字棋小游戏
- unity3d插件Daikon Forge GUI 中文教程7-高级控件slider的使用
- Unity3D DFGUI根据名称获取多个子控件代码
- Unity3D学习(2)——GUI五子棋
- Unity3D入门——GUI的Label控件
- 【unity3d脚本】判断GUI双击代码
- Unity3D笔记之OnGUI()下的自适屏
- 和小伙伴们一起学Unity3D(二)GUI
- Unity3D ARPG游戏开发《最初的幻想》之GUI背包系统实现
- Unity3d GUI 时钟脚本
- Unity3D的GUI插件(UIToolkit,GUIX)在Unity的社区里发现一个不错的UI插件----UIToolkit.
- Unity3D GUI—打字机风格脚本
- Unity3d EZGUI 多语言自适应前期设计准则
- 【Unity3D自学记录】纯GUI实现黑白棋
- unity3D——GUI基础2
- Unity3D【GUI基础二】
- Unity3d-UI插件EZGUI官方视频教程
- 006-unity3d GUI初识、贴图、自定义鼠标指针