unity3d有没有中文版 layout布局没有怎么办

Unity3D【】学习笔记-GUI控件及界面布局_花杀兮吧_百度贴吧
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&签到排名:今日本吧第个签到,本吧因你更精彩,明天继续来努力!
本吧签到人数:0可签7级以上的吧50个
本月漏签0次!成为超级会员,赠送8张补签卡连续签到:天&&累计签到:天超级会员单次开通12个月以上,赠送连续签到卡3张
关注:1贴子:
Unity3D【】学习笔记-GUI控件及界面布局
using UnityEusing System.Cusing UnityEpublic class GUITest : MonoBehaviour{
#region Label控件
//public Texture imageT
//private int imageW
//private int imageH
//private int screenW
//private int screenH
//void Start()
screenWidth = Screen.
screenHeight = Screen.
imageWidth = imageTexture.
imageHeight = imageTexture.
//void OnGUI()
GUI.Label(new Rect(100, 10, 200, 30), str);
GUI.Label(new Rect(100, 40, 200, 30), &当前屏幕宽:& + screenWidth.ToString());
GUI.Label(new Rect(100, 70, 200, 30), &当前屏幕高:& + screenHeight.ToString());
GUI.Label(new Rect(100, 120, imageWidth, imageHeight), imageTexture);
#endregion
#region Button控件
//public Texture2D buttonT
//private int frameT
//void Start()
str = &请点击按钮!&;
//void OnGUI()
GUI.Label(new Rect(10, 10, Screen.width, 30), str);
if (GUI.Button(new Rect(10, 50, buttonTexture.width, buttonTexture.height), buttonTexture))
str = &您点击了图片按钮!&;
GUI.color = Color.
GUI.backgroundColor = Color.
if (GUI.Button(new Rect(10, 200, 70, 30), &文字按钮&))
str = &您点击了文字按钮!&;
GUI.color = Color.
GUI.backgroundColor = Color.
if (GUI.RepeatButton(new Rect(10, 250, 100, 30), &按钮按下中&))
str = &按下按钮的时间:& + frameT
frameTime++;
#endregion
#region TextField&PasswordField控件
//private string userN
//private string userP
//private string loginT
//void Start()
loginTip = &请输入用户名和密码:&;
userName = &请输入用户名&;
userPassword = &请输入密码&;
//void OnGUI()
GUI.Label(new Rect(10, 10, Screen.width, 30), loginTip);
GUI.Label(new Rect(10, 50, 70, 30), &用户名:&);
userName = GUI.TextField(new Rect(60, 50, 150, 30), userName, 25);
GUI.Label(new Rect(10, 90, 70, 30), &密码:&);
userPassword = GUI.PasswordField(new Rect(60, 90, 150, 30), userPassword, &*&[0], 25);
if (GUI.Button(new Rect(10, 130, 100, 30), &登录&))
loginTip = &您输入的用户名为:& + userName + &,您输入的密码为:& + userPassword + &。&;
#endregion
#region Toolbar&Toggle控件
//private string[] toolbarTexts = new string[] { &道具&, &武器&, &护甲&, &任务物品& };
//private int toolbarS
//private bool toggleSelectedO
//private bool toggleSelectedT
//void Start()
toolbarSelected = 0;
toggleSelectedOne =
toggleSelectedTwo =
//void OnGUI()
int oldSelected = toolbarS
toolbarSelected = GUI.Toolbar(new Rect(10, 10, toolbarTexts.Length * 80, 40), toolbarSelected, toolbarTexts);
if (oldSelected != toolbarSelected)
toggleSelectedOne =
toggleSelectedTwo =
switch (toolbarSelected)
toggleSelectedOne = GUI.Toggle(new Rect(10, 70, 100, 30), toggleSelectedOne, &道具-回气散&);
toggleSelectedTwo = GUI.Toggle(new Rect(10, 120, 100, 30), toggleSelectedTwo, &道具-金疮药&);
toggleSelectedOne = GUI.Toggle(new Rect(10, 70, 100, 30), toggleSelectedOne, &武器-天罗伞&);
toggleSelectedTwo = GUI.Toggle(new Rect(10, 120, 100, 30), toggleSelectedTwo, &武器-孔雀翎&);
toggleSelectedOne = GUI.Toggle(new Rect(10, 70, 100, 30), toggleSelectedOne, &护甲-软猬甲&);
toggleSelectedTwo = GUI.Toggle(new Rect(10, 120, 100, 30), toggleSelectedTwo, &护甲-血蚕眠&);
toggleSelectedOne = GUI.Toggle(new Rect(10, 70, 150, 30), toggleSelectedOne, &任务物品-太极图&);
toggleSelectedTwo = GUI.Toggle(new Rect(10, 120, 150, 30), toggleSelectedTwo, &任务物品-真武剑&);
#endregion
#region Slider控件
//private int hsValue = 0;
//private float vsValue = 0.0f;
//void OnGUI()
hsValue = (int)GUI.HorizontalSlider(new Rect(10, 10, Screen.width - 20, 10), hsValue, 0, 100);
vsValue = GUI.VerticalSlider(new Rect(30, 30, 10, 200), vsValue, 0f, 100f);
GUI.Label(new Rect(10, 50, 300, 20), string.Format(&水平滑动条的值是{0}%。&, hsValue));
GUI.Label(new Rect(10, 70, 300, 20), string.Format(&垂直滑动条的值是{0}%。&, vsValue));
#endregion
#region ScrollView控件
//private Vector2 scrollPosition = new Vector2(0, 0);
//void OnGUI()
scrollPosition = GUI.BeginScrollView(new Rect(0, 0, 200, 200), scrollPosition, new Rect(0, 0, Screen.width, 300));
GUI.Label(new Rect(100, 40, Screen.width, 30), &测试滚动视图,测试滚动视图,测试滚动视图,测试滚动视图,&);
GUI.EndScrollView();
#endregion
#region Window控件
//private Rect windowOne = new Rect(50, 50, 400, 300);
//private Rect windowTwo = new Rect(150, 70, 800, 600);
//void OnGUI()
windowOne = GUI.Window(0, windowOne, DrawWindowOne, &MyFirstWindow&);
GUI.Window(1, windowTwo, DrawWindowTwo, &MySecondWindow&);
//private void DrawWindowTwo(int id)
string str = &窗口ID是:{0}!&;
GUI.Label(new Rect(10, 10, 200, 30), string.Format(str, id));
if (GUI.Button(new Rect(10, 50, 60, 20), &按钮&))
print(&按钮被点击了!&);
GUI.DragWindow();
//private void DrawWindowOne(int id)
string str = &窗口ID是:{0}!&;
GUI.Label(new Rect(10, 10, 200, 30), string.Format(str, id));
if (GUI.Button(new Rect(10, 50, 60, 20), &按钮&))
print(&按钮被点击了!&);
GUI.DragWindow(new Rect(0,0,windowOne.width,20));
#endregion
#region GUISkin控件
//private GUISkin myS
//private Rect windowRect = new Rect(50, 50, 400, 300);
//private string edit = &请输入字符串&;
//void Start()
mySkin = AssetDatabase.LoadAssetAtPath&GUISkin&(&Assets/GUISkin.guiskin&);
//void OnGUI()
GUI.skin = myS
GUI.Button(new Rect(100, 100, 100, 100), &自定义按钮&);
GUI.Button(new Rect(100, 250, 100, 100), &自定义按钮2&, mySkin.GetStyle(&btnStyle0&));
if (choosed = GUI.Toggle(new Rect(10, 50, 100, 30), choosed, &单项选择&))
windowRect = GUI.Window(0, windowRect, WindowOne, &窗口A&);
edit = GUI.TextField(new Rect(200, 10, 200, 20), edit, 25);
//private void WindowOne(int id)
GUI.DragWindow();
GUI.Button(new Rect(10, 20, 100, 30), &自定义按钮&);
#endregion
#region GUILayout线性布局
//private Texture2D
//void Start()
tex = AssetDatabase.LoadAssetAtPath&Texture2D&(&Assets/001.png&);
//void OnGUI()
GUILayout.BeginHorizontal();
GUILayout.Box(&开始水平布局&);
GUILayout.Button(&按钮&);
GUILayout.Label(&标签&);
GUILayout.TextField(&输入框&);
GUILayout.Box(tex);
GUILayout.EndHorizontal();
GUILayout.BeginVertical();
GUILayout.Box(&开始水平布局&);
GUILayout.Button(&按钮&);
GUILayout.Label(&标签&);
GUILayout.TextField(&输入框&);
GUILayout.Box(tex);
GUILayout.EndVertical();
#endregion
#region GUILayout控件偏移
//void OnGUI()
GUILayout.BeginArea(new Rect(0, 0, Screen.width, Screen.height));
GUILayout.BeginHorizontal();
GUILayout.BeginVertical();
GUILayout.Box(&Test1&);
GUILayout.FlexibleSpace();
GUILayout.Box(&Test2&);
GUILayout.EndVertical();
GUILayout.FlexibleSpace();
GUILayout.BeginVertical();
GUILayout.Box(&Test3&);
GUILayout.FlexibleSpace();
GUILayout.Box(&Test4&);
GUILayout.EndVertical();
GUILayout.EndHorizontal();
GUILayout.EndArea();
#endregion
#region 添加与关闭窗口
private ArrayList winAL = new ArrayList();
void Start()
winAL.Add(new Rect(winAL.Count * 100, 50, 150, 100));
icon = AssetDatabase.LoadAssetAtPath&Texture&(&Assets/Item Icons/ball_fire.png&);
void OnGUI()
for (int i = 0; i & winAL.C i++)
winAL[i] = GUILayout.Window(i, (Rect)winAL[i], AddWin, &窗口ID:& + i.ToString());
private void AddWin(int id)
GUILayout.BeginHorizontal();
GUILayout.Label(icon, GUILayout.Height(64), GUILayout.Width(64));
GUILayout.Label(&这是一个全新的窗口!&);
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
if (GUILayout.Button(&添加新窗口&))
winAL.Add(new Rect(winAL.Count * 100, 50, 150, 100));
if (GUILayout.Button(&关闭当前窗口&))
winAL.RemoveAt(id);
GUILayout.EndHorizontal();
GUI.DragWindow(new Rect(0, 0, Screen.width, Screen.height));
#endregion}
缺牙要及时修复,揭秘种植牙如何做到几十年不掉?
using UnityEusing System.Cusing UnityEusing System.IO;public class GUITest : MonoBehaviour{
#region GUI字体
//private GUISkin myS
//void Start()
mySkin = AssetDatabase.LoadAssetAtPath&GUISkin&(&Assets/GUISkin.guiskin&);
//void OnGUI()
GUI.skin = myS
GUILayout.Box(&时尚中黑简体&);
GUILayout.Button(&汉仪菱心体简&);
GUILayout.Label(&默认字体&);
#endregion
#region GUI贴图绘制
//private Texture2D texS
//private Texture2D[] currentT
//void OnGUI()
if (GUI.Button(new Rect(0, 10, 100, 50), &加载一张图片&))
texSingle = AssetDatabase.LoadAssetAtPath&Texture2D&(&Assets/Item Icons/arrow.png&);
if (GUI.Button(new Rect(0, 130, 100, 50), &加载一组图片&))
currentTex = Resources.LoadAll&Texture2D&(&&);
if (texSingle != null)
GUI.DrawTexture(new Rect(110, 10, 64, 64), texSingle, ScaleMode.StretchToFill, true, 0);
if (currentTex != null)
for (int i = 0; i & currentTex.L i++)
GUI.DrawTexture(new Rect(110 + i * 80, 130, 64, 64), currentTex[i], ScaleMode.StretchToFill, true, 0);
#endregion
#region GUI人物移动
//private Texture2D[] currentT
//private Texture2D[] upT
//private Texture2D[] downT
//private Texture2D[] leftT
//private Texture2D[] rightT
//private int nowF
//private int fps = 4;
//private int x = 0;
//private int y = 0;
//void Start()
upTex = Resources.LoadAll&Texture2D&(&Walk/Up&);
downTex = Resources.LoadAll&Texture2D&(&Walk/Down&);
leftTex = Resources.LoadAll&Texture2D&(&Walk/Left&);
rightTex = Resources.LoadAll&Texture2D&(&Walk/Right&);
currentTex = downT
//void OnGUI()
DrawWalkAnim(currentTex, new Rect(200 + x, 200 + y, 64, 64));
GUILayout.BeginHorizontal();
if (GUILayout.Button(&向左&))
currentTex = leftT
GUILayout.BeginVertical();
if (GUILayout.Button(&向上&))
currentTex = upT
if (GUILayout.Button(&向下&))
currentTex = downT
GUILayout.EndVertical();
if (GUILayout.Button(&向右&))
currentTex = rightT
GUILayout.EndHorizontal();
//private void DrawWalkAnim(Texture2D[] currentTex, Rect rect)
GUILayout.Label(string.Format(&当前播放的是第{0}帧。&, nowFrame));
GUI.DrawTexture(rect, currentTex[nowFrame], ScaleMode.StretchToFill, true, 0);
time += Time.deltaT
if (time &= 1.0 / fps)
nowFrame++;
if (nowFrame &= currentTex.Length)
nowFrame = 0;
#endregion
#region 使用材质制作人物移动
//private Texture2D[] currentT
//private Texture2D[] upT
//private Texture2D[] downT
//private Texture2D[] leftT
//private Texture2D[] rightT
//private int nowF
//private int fps = 4;
//private int x = 0;
//private int y = 0;
//private GameO
//void Start()
upTex = Resources.LoadAll&Texture2D&(&Walk/Up&);
downTex = Resources.LoadAll&Texture2D&(&Walk/Down&);
leftTex = Resources.LoadAll&Texture2D&(&Walk/Left&);
rightTex = Resources.LoadAll&Texture2D&(&Walk/Right&);
hero = GameObject.Find(&hero&);
currentTex = downT
//void OnGUI()
DrawWalkAnim(currentTex, new Rect(200 + x, 200 + y, 64, 64));
GUILayout.BeginHorizontal();
if (GUILayout.Button(&向左&))
currentTex = leftT
hero.transform.Translate(Vector3.right * 10);
GUILayout.BeginVertical();
if (GUILayout.Button(&向上&))
currentTex = upT
if (GUILayout.Button(&向下&))
currentTex = downT
GUILayout.EndVertical();
if (GUILayout.Button(&向右&))
currentTex = rightT
GUILayout.EndHorizontal();
//private void DrawWalkAnim(Texture2D[] currentTex, Rect rect)
GUILayout.Label(string.Format(&当前播放的是第{0}帧。&, nowFrame));
//GUI.DrawTexture(rect, currentTex[nowFrame], ScaleMode.StretchToFill, true, 0);
hero.GetComponent&MeshRenderer&().material.mainTexture = currentTex[nowFrame];
time += Time.deltaT
if (time &= 1.0 / fps)
nowFrame++;
if (nowFrame &= currentTex.Length)
nowFrame = 0;
#endregion
#region GUI开始游戏菜单的制作
private Texture texT
void Start()
texTitle = Resources.Load&Texture&(&bg&);
void OnGUI()
GUI.DrawTexture(new Rect((Screen.width - texTitle.width) / 2, 50, texTitle.width, texTitle.height), texTitle, ScaleMode.StretchToFill, true, 0);
GUI.Button(new Rect((Screen.width - 150) / 2, 300, 150, 30), &开始游戏&);
GUI.Button(new Rect((Screen.width - 150) / 2, 350, 150, 30), &读取游戏&);
GUI.Button(new Rect((Screen.width - 150) / 2, 400, 150, 30), &关于游戏&);
GUI.Button(new Rect((Screen.width - 150) / 2, 450, 150, 30), &退出游戏&);
#endregion}
补上最后一块的图吧!
贴吧热议榜
使用签名档&&
保存至快速回贴当前位置: >
GUI布局类 GUILayout
时间: 09:08 来源:Unity之家 作者:unity.jb51.net 浏览:
GUILayout& 类&& GUILayout是用于UnityGUI自动布局的类。 参见:GUI Layout tutoria&&& 类方法&&& ◆ static function BeginArea(screenRect : Rect) : void&&& ◆ static function BeginArea(screenRect : rect, text : string) : void&&& ◆ static function BeginArea(screenRect : Rect, image : Texture) : void&&&&&&& ◆ static function BeginArea(screenRect : Rect, content : GUIContent) : void&&& ◆ static function BeginArea(screenRect : Rect, style : GUIStyle) : void&&& ◆ static function BeginArea(screenRect : Rect, text : string, style : GUIStyle) : void&&& ◆ static function BeginArea(screenRect : Rect, image : Texture, style : GUIStyle) : void&&& ◆ static function BeginArea(screenRect : Rect, content : GUIContent, style : GUIStyle) : void&&& //&& 描述:在屏幕的固定区域开始一个GUI空间的GUILayout块。&&& 默认的,任何使用GUILayout制作的GUI空间都放置在屏幕的左上角。如果你想在任一区域放置一系列自动布局的控件,使用GUILayout.BeginArea定义一个新的区域以便自动布局系统可以使用它。&&& 参数&&&& text可选的显示在该区域中的文本&&&& image& 可选的显示在该区域中的纹理&&&& content& 可选的在该区域顶部显示的文本,图片和提示&&&& style& 使用的风格。如果留空,空的GUIStyle(GUIStyle.none)将被使用,给出一个透明的背景。参见:EndArea&&& function OnGUI()&&& {&&&& GUILayout.BeginArea(Rect(200, 200, 100, 100));&&&& GUILayout.Button(“Click me”);&&&& GUILayout.Button(“Or me”);&&&&& GUILayout.EndArea();&&& }&&& 在混合GUILayout代码是这个函数是非常有用的。必须与EndArea调用匹配。BeginArea / EndArea不能嵌套。&&& ◆ static function BeginHorizontal(params options : GUILayoutOption[]): void&&& ◆ static function BeginHorizontal(style : GUIStyle, params options : GUILayoutOption[]): void&& //& 描述:开始一个水平控件组。&&&&& 所有在这个元素内部渲染的空间将被一个接一个的水平放置,改组必须调用EndHorizontal关闭。参见:GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight&&&& 参数&&&& style这个风格用于背景图片和填充值。如果留空,背景是透明的。&&&& options& 一个可选的布局选项的列表。它用来指定额外的布局属性。任何在这个设置的值将覆盖由style定义的设置。&&&& ◆ static function BeginScrollView(scrollPosition : Vector2, params options : GUILayoutOption[]) : Vector2&&& ◆ static function BeginScrollView(scrollPosition : Vector2, horizontalScrollbar : GUIStyle, verticalScrollbar : GUIStyle, params options : GUILayoutOption[]) : Vector2&&& ◆ static function BeginScrollView(scrollPosition : Vector2, alwaysShowHorizontal : bool, alwaysShowVertical : bool, params options : GUILayoutOption[]) : Vector2&&& ◆ static function BeginScrollView(scrollPosition : Vector2, style : GUIStyle) : Vector2&&& ◆ static function BeginScrollView(scrollPosition : Vector2, alwaysShowHorizontal : bool, alwaysShowVertical : bool, horizontalScrollbar : GUIStyle, verticalScrollbar : GUIStyle,& params options : GUILayoutOption[]) : Vector2&&& ◆ static function BeginScrollView(scrollPosition : Vector2, alwaysShowHorizontal : bool, alwaysShowVertical : bool, horizontalScrollbar : GUIStyle, verticalScrollbar : GUIStyle,& background : GUIStyle, params options : GUILayoutOption[]) : Vector2& //&& 描述:开始一个自动布局滚动视。&&& 参数:&&& scrollPostion 用来显示的位置&&& alwaysShowHorizontal& 可选的参数用来总是显示水平滚动条。如果为假或者留空,它将只在ScrollView中的内容比滚动视宽时显示。&&& alwaysShowVertical 可选的参数用来总是显示垂直滚动条。如果为假或者留空,它将只在ScrollView中的内容比滚动视高时显示。&&&&&& horizontalScrollbar 用于水平滚动条的可选GUIStyle。如果不设置,将使用当前GUISkin的horizontalScrollbar。&&& verticalScrollbar 用于垂直滚动条的可选GUIStyle。如果不设置,将使用当前GUISken的verticalScrollbar风格。&&& 返回Vector2 C 修改过的scrollPosition。回传这个变量,如下的例子:自动布局滚动视,将使用任何你放置在它们中的内容并正常显示出来。如果他不适合,将显示滚动条,BeginScrollView的调用总是与EndScrollView的调用匹配。&&& var scrollPosition : Vector2;& //&& 这个变量对于空间来说就是这个滚动视查看子元素的位置。&&& var longString = “This is a long-ish string”;&&& //&& 显示在滚动视中的字符串,下面两个按钮添加,清除这个字符串。&&& function OnGUI()&&& {&scrollPosition = GUILayout.BeginScrollView(scrollPosition,& GUILayout.Width(100),& GUILayout.Height(100));& //开始一个滚动视,所有矩形被自动计算。它将使用任何可用的空间并确保内容排列正确 ,这是小的最后两参数来强制滚动条出现&&& GUILayout.Height(longString);&&&& if(GUILayout.Button(“Clear”)&& //& 添加一个简单的标签到滚动视内部。注意滚动条如何与文字换行正确的工作。&&& longString = “”; //结束我们上面开始的滚动条&& GUILayout.EndScrollView();&&& //添加一个按钮来消除字符串。这个是在滚动区域内部,因此它也将被滚动。注意按钮如何变窄为垂直滚动条留出空间&& if(GUILayout.Button(“Add MoreText”))&&& //现在我们在滚动视外边添加一个按钮 C 这将显示在滚动区域的下边&& {&&&& longString += “nHere is another line.”;&&&& }&&& ◆ static function Box(params option : GUILayoutOption[]) : void&&& ◆ static function Box(style : GUIStyle, params option : GUILayoutOption[]) : void&&& //& 描述:开始一个垂直控件组。所有在这个元素内部渲染的空间将被一个接一个地垂直放置。改组必须调用EndVertical关闭。&&& 参数&&& style 这个风格将用于背景图片和填充值,如果留空,背景是透明的。&&& options& 一个可选的布局选项的列表。它用来指定额外的布局属性。任何在这里设置的值将覆盖由style定义的设置。&&&& 参见:GUILayout.Width,& GUILayout.Height,& GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.&&& ◆ static function Box(image : Texture, params option : GUILayoutOption[]) : void&&& ◆ static function Box(text : string, params option : GUILayoutOption[]) : void&&& ◆ static function Box(contend : GUIContent, params option : GUILayoutOption[]) : void&&& ◆ static function Box(image : Texture, style : GUIStyle, params option : GUILayoutOption[]) : void&&& ◆ static function Box(text : string, style : GUIStyle, params option : GUILayoutOption[]) : void&&& ◆ static function Box(contend : GUIContent, style : GUIStyle, params option : GUILayoutOption[]) : void& //& 描述:制作一个自动布局box,这将制作一个实心box,如果你想制作一个包含一些内容的box,使用一个子组函数的&&& 参数&&& text 显示在该box上的文本&&& image显示在该box上的Texture&&& content用于这个box的文本,图形和提示&&& style 使用的风格。如果不设置,将使用当前的GUISkin的box风格。&&& options& 一个可选的布局选项的列表。它用来指定额外的布局属性。任何在这里设置的值将覆盖由style定义的设置。&&& 风格参数(BeginHorizontal, BeginVertical, 等等) 参见:GUILayout.Width,& GUILayout.Height,& GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.&&& ◆ static function Button(image : Texture, params options : GUILayoutOption[]) : bool&&& ◆ static function Button(text : string, params options : GUILayoutOption[]) : bool&&& ◆ static function Button(content : GUIContent, params options : GUILayoutOption[]) : bool&&& ◆ static function Button(image : Texture, style : GUIStyle, params options : GUILayoutOption[]) : bool&&& ◆ static function Button(text : string, style : GUIStyle, params options : GUILayoutOption[]) : bool&&& ◆ static function Button(content : GUIContent, style : GUIStyle, params options : GUILayoutOption[]) : bool&&& //&& 描述:制作一个简单的按钮,用户点击它们的时候就会有事情发生。 返回bool C true当用户单击按钮时。&&&& 参数&&&& text 显示在该按钮上的文本&&&& image显示在该按钮上的Texture&&&& content用于这个按钮的文本,图形和提示。&&&& style 使用的风格。如果不设置,将使用当前的GUISkin的button风格。&&&& options& 一个可选的布局选项的列表。它用来指定额外的布局属性。任何在这里设置的值将覆盖由style定义的设置。&&& 参见:GUILayout.Width,& GUILayout.Height,& GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight&&& ◆ static functioin EndArea() : void&&& //&&& 描述:关闭由BeginArea开始的GUILayout块&&& ◆ static function EndHorizontal() : void&&& //&& 描述:关闭一个开始于BeginHorizontal的组&&& ◆ static functioin EndScrollView() : void&&& //&&&& 描述:结束由BeginScrollView调用开始的滚动视。&&& ◆ static functioin EndVertical() : void&&& //&&&& 描述:关闭一个开始于BeginVertical的组&&& ◆ static functioin ExpandHeight(expand : bool) : GUILayoutOption&&& //&& 描述:传递给一个空间的选项来允许或不允许垂直扩展。&&& ◆ static functioin ExpandWidth(expand : bool) : GUILayoutOption&&& //&&& 描述:传递给一个空间的选项来允许或不允许水平扩展。&&& ◆ static functioin FlexibleSpace() : void&&&& //&&& 描述:插入一个灵活的空格元素& 灵活的空格用来填充一个布局中任何遗漏的空间。&&& ◆ static functioin Height(height : float) : GUILayoutOption&&&& 描述:传递给空间的选项以便给它一个绝对高度。&&& ◆ static functioin HorizontalScrollbar(value : float, size : float, leftValue : float, rightValue : float, params options : GUILayoutOption[]) : float&&& ◆ static functioin HorizontalScrollbar(value : float, size : float, leftValue : float, rightValue : float, style : GUIStyle, params options : GUILayoutOption[]) : float&& //&&& 描述:一个水平滚动条。滚动条可以用来滚动文档。大多数情况下,你会使用滚动视代替。&&&& 返回floar C 修改后的值。这可以通过拖动这个滚动条,或者单击两端的箭头来改变。&&&& 参数&&&& value在min和max之间的位置&&&& size 能看见多大?&&&& leftValue滚动条左端的值&&&& rightValue& 滚动条右端的值&&&& style 用于滚动条背景的风格。如果不设置,将使用当前GUISkin的horizontalScrollbar&&&& options 一个可选的布局选项的列表。它用来指定额外的布局属性。任何在这里设置的值将覆盖由style定义的设置。&&&& 参见:GUILayout.Width,& GUILayout.Height,& GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight&&& 找到额外的元素:在滚动条两端的按钮将在当前皮肤中搜索“leftButton”和“rightButton”作为风格,滚动条的滑块(你拖动的东西)将搜索并使用名为“thumb”的风格。这将使用下面的风格名来决定该按钮的尺寸/位置,&&&& scrollPos = GUILayout.HorizontalScrollbar(scrollPos, 1, 0, 100, “MyScrollbar”);&&&& MyScrollbarleftButton - 用于左侧按钮的风格位置&&&& MyScrollbarrightButton - 用于右侧按钮的风格位置&&&& MyScrollbarthumb - 用于滑块的风格名称&&& ◆ static functioin HorizontalSlider(value : float, leftValue : float, rightValue : float, params options : GUILayoutOption[]) : float&&& ◆ static functioin HorizontalSlider(value : float, leftValue : float, rightValue : float, slider : GUIStyle, thumb : GUIStyle, params options : GUILayoutOption[]) : float& //&& 描述:一个用户可以拖动的滑杆。可以在min和max之间取一个值。 返回float C 被用户设置的值。&&& 参数&&& value滑块显示的值。这个决定可拖动滑块的位置。&&& leftValue滑杆左端的值。&&& rightValue& 滑杆右边的值。&&& slider用于显示拖动区域的GUIStyle。如果不设置,将使用当前GUISkin的horizontalSlider。&&&& thumb& 用于显示拖动块的GUISkin。如果不设置,将使用当前的GUISkin的horizontalSliderThumb&&& options& 一个可选的布局选项的列表。它用来指定额外的布局属性。任何在这里设置的值将覆盖由style定义的设置。&&& 参见:GUILayout.Width,& GUILayout.Height,& GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.&&& ◆ static function Label(image : Texture, params options : GUILayoutOption[]) : void&&& ◆ static function Label(text : string, params options : GUILayoutOption[]) : void&&& ◆ static function Label(content : GUIContent, params options : GUILayoutOption[]) : void&&& ◆ static function Label(image : Texture, style : GUIStyle, params options : GUILayoutOption[]) : void&&& ◆ static function Label(text : string, style : GUIStyle, params options : GUILayoutOption[]) : void&&& ◆ static function Label(content: GUIContent, style : GUIStyle, params options : GUILayoutOption[]) : void&& //&& 描述:制作一个自动布局label& 标签没有用户交互。不会获取鼠标点击并总是以普通风格渲染。如果你想制作一个可视化响应用户输出的控件,使用一个Box控件。&&& 参数&&& text 显示在该标签上的文本。&&& image显示在标签上的Texture。&&& content用于这个标签的文本,图形和提示。&&& style 使用的风格。如果不设置。将使用当前GUISkin的label。&&& options& 一个可选的布局选项的列表。它用来指定额外的布局属性。任何在这里设置的值将覆盖由style定义的设置。&&& 参见:GUILayout.Width,& GUILayout.Height,& GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.&&&& ◆ static function MaxHeight(maxHeight : float) : GUILayoutOption&&& //&&&& 描述:传递给控件的选项来指定一个最大高度。&&& ◆ static function MaxWidth(maxWidth : float) : GUILayoutOption&&& //&& 描述:传递给控件的选项来指定一个最大宽度。&&& ◆ static function MinHeight(minHeight : float) : GUILayoutOption&&& //&&&& 描述:传递给控件的选项来指定一个最小高度。&&& ◆ static function MinWidth(minWidth : float) : GUILayoutOption&&& //&&&& 描述:传递给控件的选项,来指定一个最小宽度&&& ◆ static function PasswordField(password : string,& maskChar : char, params options : GUILayoutOption[]) : string&&& ◆ static function PasswordField(password : string,& maskChar : char, maxLength : int, params options : GUILayoutOption[]) : string&&& ◆ static function PasswordField(password : string,& maskChar : char, style : GUIStyle, params options : GUILayoutOption[]) : string&&& ◆ static function PasswordField(password : string,& maskChar : char, maxLength : int, style : GUIStyle, params options : GUILayoutOption[]) : string& //& 描述:制作一个用户可以输入密码的文本域。返回string C 编辑过的密码。&&& 参数&&& password 用于编辑的密码。这个函数返回值应该被赋回这个字符串。&&& maskChar 用来隐藏密码的字符。&&& maxLength 字符串的最大长度。如果不设置,用户可以一直输入。&&& style 使用的风格。如果不设置,将使用当前GUISkin的textField风格。&&& 如下的例子:&&& var passwordToEdit = “My Password”;&&& function OnGUI()&&& {&&&&& passwordToEdit = GUILayout.PasswordField(passwordToEdit, “*”, 25);// 制作一个密码与来调整stringToEdit。&&& }&&& ◆ static function RepeatButton(image : Texture, params options : GUILayoutOption[]) : bool&&& ◆ static function RepeatButton(text : string, params options : GUILayoutOption[]) : bool&&& ◆ static function RepeatButton(content : GUIContent, params options : GUILayoutOption[]) : bool&&& ◆ static function RepeatButton(image : Texture, style : GUIStyle, params options : GUILayoutOption[]) : bool&&& ◆ static function RepeatButton(text : string, style : GUIStyle, params options : GUILayoutOption[]) : bool&&& ◆ static function RepeatButton(content : GUIContent, style : GUIStyle, params options : GUILayoutOption[]) : bool& //&& 描述:制作一个重复按钮,只要用户按住鼠标这个按钮一直返回真。 返回bool - /true/当用户按住按钮时&&& 参数&&& text显示在该按钮上的文本。&&& image& 显示在该按钮上的Texture。&&& content& 用于这个按钮的文本,图形和提示。&&& style使用的风格,如果不设置,将使用当前GUISkin的button风格。&&& options& 一个可选的布局选项的列表。它用来指定额外的布局属性。任何在这里设置的值将覆盖由style定义的设置。
(责任编辑:脚印)
免责声明:Unity之家部分内容来源于互联网,如有侵权,请联系我们,本站将立即进行处理。
猜你也喜欢看这些 ??????
其他类型的Unity入门 ??????}

我要回帖

更多关于 unity3d guilayout 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信