GUI02Controls.docx

上传人:b****3 文档编号:4472597 上传时间:2022-12-01 格式:DOCX 页数:17 大小:98.86KB
下载 相关 举报
GUI02Controls.docx_第1页
第1页 / 共17页
GUI02Controls.docx_第2页
第2页 / 共17页
GUI02Controls.docx_第3页
第3页 / 共17页
GUI02Controls.docx_第4页
第4页 / 共17页
GUI02Controls.docx_第5页
第5页 / 共17页
点击查看更多>>
下载资源
资源描述

GUI02Controls.docx

《GUI02Controls.docx》由会员分享,可在线阅读,更多相关《GUI02Controls.docx(17页珍藏版)》请在冰豆网上搜索。

GUI02Controls.docx

GUI02Controls

Controls控制、管理

ReferenceManual>GUIScriptingGuide>Controls

ControlTypes

ThereareanumberofdifferentGUIControlsthatyoucancreate.ThissectionlistsalloftheavailabledisplayandinteractiveControls.ThereareotherGUIfunctionsthataffectlayoutofControls,whicharedescribedintheLayoutsectionoftheGuide.

有一些不同的图形用户界面控件,您可以建立。

本节列出了所有可用的显示和交互控制。

还有其他的图形用户界面功能,影响布局的控制,这说明在布局节指南。

Label标签,

TheLabelisnon-interactive.Itisfordisplayonly.Itcannotbeclickedorotherwisemoved.Itisbestfordisplayinginformationonly.

标签非交互式。

它是为只显示。

它不能被点击或以其他方式移动。

这是最好的展示仅供参考。

/*GUI.Labelexample*/

functionOnGUI(){

GUI.Label(Rect(25,25,100,30),"Label");

}

TheLabelcreatedbytheexamplecode

Button按钮

TheButtonisatypicalinteractivebutton.Itwillrespondasingletimewhenclicked,nomatterhowlongthemouseremainsdepressed.Theresponseoccursassoonasthemousebuttonisreleased.

按钮是一个典型的互动式按钮。

这将回应一个单一的时候点击,无论多长的老鼠仍然低迷。

发生的反应尽快鼠标按钮被释放。

BasicUsage基本用法

InUnityGUI,Buttonswillreturntruewhentheyareclicked.ToexecutesomecodewhenaButtonisclicked,youwrapthetheGUI.Buttonfunctioninanifstatement.InsidetheifstatementisthecodethatwillbeexecutedwhentheButtonisclicked.

在UnityGUI,按钮将返回真正当他们点击。

当按下Button时,会执行一些代码,你的总结的GUI.Button功能if语句。

在if语句的代码,将被处死时,按下按钮。

/*GUI.Buttonexample*/

functionOnGUI(){

if(GUI.Button(Rect(25,25,100,30),"Button")){

//ThiscodeisexecutedwhentheButtonisclicked

}

}

TheButtoncreatedbytheexamplecode

RepeatButton重复按钮

RepeatButtonisavariationoftheregularButton.Thedifferenceis,RepeatButtonwillrespondeveryframethatthemousebuttonremainsdepressed.Thisallowsyoutocreateclick-and-holdfunctionality.

RepeatButton是一个经常变化的巴顿。

所不同的是,RepeatButton将响应每一帧的鼠标按钮仍然低迷。

这可以让你创造单击保持功能

BasicUsage基本用法

InUnityGUI,RepeatButtonswillreturntrueforeveryframethattheyareclicked.ToexecutesomecodewhiletheButtonisbeingclicked,youwrapthetheGUI.RepeatButtonfunctioninanifstatement.InsidetheifstatementisthecodethatwillbeexecutedwhiletheRepeatButtonremainsclicked.

在UnityGUI,RepeatButtons将返回对于每一帧,他们点击。

执行一些代码,而被按下按钮,你的总结的GUI.RepeatButton功能if语句。

在if语句的代码,将被处死,而RepeatButton仍然点击。

/*GUI.RepeatButtonexample*/

functionOnGUI(){

if(GUI.RepeatButton(Rect(25,25,100,30),"RepeatButton")){

//ThiscodeisexecutedeveryframethattheRepeatButtonremainsclicked

}

}

TheRepeatButtoncreatedbytheexamplecode

TextField文字栏

TheTextFieldControlisaninteractive,editablesingle-linefieldcontainingatextstring.

对TextField的控制是一个互动,编辑单线领域包含的文本字符串。

BasicUsage基本用法

TheTextFieldwillalwaysdisplayastring.YoumustprovidethestringtobedisplayedintheTextField.Wheneditsaremadetothestring,theTextFieldfunctionwillreturntheeditedstring.

对TextField的将始终显示一个字符串。

您必须提供字符串显示在TextField的。

当编辑向字符串,TextField的函数将返回字符串的编辑。

/*GUI.TextFieldexample*/

vartextFieldString="textfield";

functionOnGUI(){

textFieldString=GUI.TextField(Rect(25,25,100,30),textFieldString);

}

TheTextFieldcreatedbytheexamplecode

TextArea文本区域

TheTextAreaControlisaninteractive,editablemulti-lineareacontainingatextstring.

该文本控制是一个互动,编辑多线地区包含的文本字符串。

BasicUsage基本用法

TheTextAreawillalwaysdisplayastring.YoumustprovidethestringtobedisplayedintheTextArea.Wheneditsaremadetothestring,theTextAreafunctionwillreturntheeditedstring.

该文本将始终显示一个字符串。

您必须提供字符串显示在文本。

当编辑向字符串,函数将返回文本的编辑字符串。

/*GUI.TextAreaexample*/

vartextAreaString="textarea";

functionOnGUI(){

textAreaString=GUI.TextArea(Rect(25,25,100,30),textAreaString);

}

TheTextAreacreatedbytheexamplecode

Toggle触发器

TheToggleControlcreatesacheckboxwithapersistenton/offstate.Theusercanchangethestatebyclickingonit.

切换控制在创建一个复选框,以持续的开/关状态。

用户可以改变国家按一下它。

BasicUsage基本用法

TheToggleon/offstateisrepresentedbyatrue/falseboolean.YoumustprovidethebooleanasaparametertomaketheTogglerepresenttheactualstate.TheTogglefunctionwillreturnanewbooleanvalueifitisclicked.Inordertocapturethisinteractivity,youmustassignthebooleantoacceptthereturnvalueoftheTogglefunction.

的开启/关闭状态由一个真/假布尔。

您必须提供布尔作为参数,使切换代表的实际状况。

的切换函数将返回一个新的布尔值如果是点击。

为了抓住这个互动,您必须指定布尔接受返回值的切换功能。

/*GUI.Toggleexample*/

vartoggleBool=true;

functionOnGUI(){

toggleBool=GUI.Toggle(Rect(25,25,100,30),toggleBool,"Toggle");

}

TheTogglecreatedbytheexamplecode

Toolbar工具栏

TheToolbarControlisessentiallyarowofButtons.OnlyoneoftheButtonsontheToolbarcanbeactiveatatime,anditwillremainactiveuntiladifferentButtonisclicked.ThisbehavioremulatesthebehaviorofatypicalToolbar.YoucandefineanarbitrarynumberofButtonsontheToolbar.

工具栏的控制基本上是一排按钮。

只有一个按钮在工具栏上可以积极的时间,而且将仍然有效,直到一个不同的按钮被按下。

此行为模拟的行为,典型的工具栏。

您可以定义任意数量的按钮在工具栏上。

BasicUsage基本用法

TheactiveButtonintheToolbaristrackedthroughaninteger.Youmustprovidetheintegerasanargumentinthefunction.TomaketheToolbarinteractive,youmustassigntheintegertothereturnvalueofthefunction.ThenumberofelementsinthecontentarraythatyouprovidewilldeterminethenumberofButtonsthatareshownintheToolbar.

积极按钮,工具栏来追踪一个整数。

您必须提供整数作为参数的函数。

为了使工具栏的互动,您必须指定整数的返回值的函数。

元素个数的数组的内容将决定您所提供的数目的按钮,显示在工具栏。

/*GUI.Toolbarexample*/

vartoolbarInt=0;

vartoolbarStrings:

String[]=["Toolbar1","Toolbar2","Toolbar3"];

functionOnGUI(){

toolbarInt=GUI.Toolbar(Rect(25,25,250,30),toolbarInt,toolbarStrings);

}

TheToolbarcreatedbytheexamplecode

SelectionGrid网格选择形式

TheSelectionGridControlisamulti-rowToolbar.Youcandeterminethenumberofcolumnsandrowsinthegrid.OnlyoneButtoncanbeactiveattime.

该SelectionGrid控制是一个多行工具栏。

您可以决定列数和行的网格。

只有一个按钮可以发挥积极作用时。

BasicUsage

TheactiveButtonintheSelectionGridistrackedthroughaninteger.Youmustprovidetheintegerasanargumentinthefunction.TomaketheSelectionGridinteractive,youmustassigntheintegertothereturnvalueofthefunction.ThenumberofelementsinthecontentarraythatyouprovidewilldeterminethenumberofButtonsthatareshownintheSelectionGrid.Youalsocandictatethenumberofcolumnsthroughthefunctionarguments.

积极按钮SelectionGrid跟踪通过一个整数。

您必须提供整数作为参数的函数。

为了使SelectionGrid互动,您必须指定整数的返回值的函数。

元素个数的数组的内容将决定您所提供的数目的按钮,显示在SelectionGrid。

您也可以决定列数通过函数参数。

/*GUI.SelectionGridexample*/

varselectionGridInt:

int=0;

varselectionStrings:

String[]=["Grid1","Grid2","Grid3","Grid4"];

functionOnGUI(){

selectionGridInt=GUI.SelectionGrid(Rect(25,25,100,30),selectionGridInt,selectionStrings,2);

}

TheSelectionGridcreatedbytheexamplecode

HorizontalSlider水平滑块

TheHorizontalSliderControlisatypicalhorizontalslidingknobthatcanbedraggedtochangeavaluebetweenpredeterminedminandmaxvalues.

该HorizontalSlider控制是一个典型的横向滑动旋钮,可拖到变化之间的值预先确定最大和最小的价值观。

BasicUsage

ThepositionoftheSliderknobisstoredasafloat.Todisplaythepositionoftheknob,youprovidethatfloatasoneoftheargumentsinthefunction.Therearetwoadditionalvaluesthatdeterminetheminimumandmaximumvalues.Ifyouwantthesliderknobtobeadjustable,assigntheslidervaluefloattobethereturnvalueoftheSliderfunction.

的立场,滑块旋钮是储存为float。

要显示的位置旋钮,您提供的浮法之一的论点的功能。

有两个额外的价值,确定最低和最高值。

如果你想滑块调节旋钮是,转让价值浮动滑块将返回值滑块功能。

/*HorizontalSliderexample*/

varhSliderValue:

float=0.0;

functionOnGUI(){

hSliderValue=GUI.HorizontalSlider(Rect(25,25,100,30),hSliderValue,0.0,10.0);

}

TheHorizontalSlidercreatedbytheexamplecode

VerticalSlider垂直滑块

TheVerticalSliderControlisatypicalverticalslidingknobthatcanbedraggedtochangeavaluebetweenpredeterminedminandmaxvalues.

该VerticalSlider控制是一个典型的垂直滑动旋钮,可拖到变化之间的值预先确定最大和最小的价值观。

BasicUsage

ThepositionoftheSliderknobisstoredasafloat.Todisplaythepositionoftheknob,youprovidethatfloatasoneoftheargumentsinthefunction.Therearetwoadditionalvaluesthatdeterminetheminimumandmaximumvalues.Ifyouwantthesliderknobtobeadjustable,assigntheslidervaluefloattobethereturnvalueoftheSliderfunction.

的立场,滑块旋钮是储存为float。

要显示的位置旋钮,您提供的浮法之一的论点的功能。

有两个额外的价值,确定最低和最高值。

如果你想滑块调节旋钮是,转让价值浮动滑块将返回值滑块功能。

/*VerticalSliderexample*/

varvSliderValue:

float=0.0;

functionOnGUI(){

vSliderValue=GUI.VerticalSlider(Rect(25,25,100,30),vSliderValue,10.0,0.0);

}

TheVerticalSlidercreatedbytheexamplecode

HorizontalScrollbar水平卷动条

TheHorizontalScrollbarControlissimilartoaSliderControl,butvisuallysimilartoScrollingelementsforwebbrowsersorwordprocessors.ThiscontrolisusedtonavigatetheScrollViewControl.

控制的HorizontalScrollbar类似滑盖控制,但视力类似滚动内容的Web浏览器或Word处理器。

这是用来控制导航ScrollView控制。

BasicUsage

HorizontalScrollbarsareimplementedidenticallytoHorizontalSliderswithoneexception:

ThereisanadditionalargumentwhichcontrolsthewidthoftheScrollbarknobitself.

横向滚动条执行相同的横向滑块有一个例外:

有一个额外的参数控制的宽度滚动旋钮本身。

/*HorizontalScrollbarexample*/

varhScrollbarValue:

float;

functionOnGUI(){

hScrollbarValue=GUI.HorizontalScrollbar(Rect(25,25,100,30),hScrollbarValue,1.0,0.0,10.0);

}

TheHorizontalScrollbarcreatedbytheexamplecode

VerticalScrollbar垂直卷动条

TheVerticalScrollbarControlissimilartoaSliderControl,butvisuallysimilartoScrollingelementsforwebbrowsersorwordprocessors.ThiscontrolisusedtonavigatetheScrollViewControl.

控制的VerticalScrollbar类似滑盖控制,但视力类似滚动内容的Web浏览器或Word处理器。

这是用来控制导航ScrollView控制。

BasicUsage

VerticalScrollbarsareimplementedidenticallytoVerticalSliderswithoneexception:

Thereisanadditi

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高中教育 > 语文

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1