位置: 编程技术 - 正文

Label控件、BOX控件、Button控件、RepeatButton控件(label控件的作用)

编辑:rootadmin
Label控件:文本Labelfunction OnGUI(){ GUI.Label(Rect(,,,),"Hello World!"); }图片Labelvar textureToDisplay:Texture2D;function OnGUI(){ GUI.Label(Rect(,,textureToDisplay.width,textureToDisplay.height),textureToDisplay); }Box控件:文本Boxfunction OnGUI(){ GUI.Box(Rect(0,0,Screen.width*0.5,Screen.height*0.5),"This is a title!");}图片Boxvar textureToDisplay:Texture2D;function OnGUI(){ GUI.Box(Rect(,,textureToDisplay.width,textureToDisplay.height),textureToDisplay);}Button控件:var btnTexture:Texture;//按钮图片function OnGUI(){ if(!btnTexture) { //如果图片未设置,输出错误提示到控制台 Debug.LogError("Please assign a texture on the inspector"); return; } //按下图片按钮 if(GUI.Button(Rect(,,,),btnTexture)) { Debug.Log("Clicked the button with an image"); } //按下文字按钮 if(GUI.Button(Rect(,,,),"Click")) { Debug.Log("Clicked the button with text"); }}RepeatButton控件:Repeat Button会在鼠标左键按下期间一直返回truevar btnTexture:Texture;//按钮图片function OnGUI(){ if(!btnTexture) { //如果图片未设置,那么显示提示 Debug.LogError("Please assign a texture on the inspector"); return; } //按下图片按钮 if(GUI.RepeatButton(Rect(,,,),btnTexture)) { Debug.Log("Clicked the button with an image"); } //按下文字按钮 if(GUI.RepeatButton(Rect(,,,),"Click")) { Debug.Log("Clicked the button with text"); }}

推荐整理分享Label控件、BOX控件、Button控件、RepeatButton控件(label控件的作用),希望有所帮助,仅作参考,欢迎阅读内容。

Label控件、BOX控件、Button控件、RepeatButton控件(label控件的作用)

文章相关热门搜索词:combo box控件使用,label控件用法,combo box控件使用,label控件用法,label控件常用属性,label 控件,label控件用法,label控件怎么调位置,内容如对您有帮助,希望把文章链接给更多的朋友!

Slider控件、Scrollbar控件、ScrollView控件、Window窗口、GUISkin控件样式 Slider控件:varhSliderValue:float=0.0;//水平滑动条数varvSliderValue:float=0.0;//垂直滑动条数functionOnGUI(){hSliderValue=GUI.HorizontalSlider(Rect(,,,),hSliderValue,0.0,.0);G

unity3D 摇一摇功能 privatefloatnew_y;privatefloatd_y;privatefloatold_y;voidUpdate(){new_y=Input.acceleration.y;d_y=new_y-old_y;old_y=new_y;if(d_y1){//摇动事件//}}重力输入:使用Input.acceleration即可获得

Visual Studio Tools for Unity安装目录,Visual Studio Tools.unitypackage VisualStudioToolsforUnity安装目录D:ProgramFiles(x)MicrosoftVisualStudio.0Common7IDEExtensionsMicrosoftVisualStudioToolsforUnity这里可以找到VisualStudioTools.unitypackage

本文链接地址:https://www.jiuchutong.com/biancheng/369354.html 转载请保留说明!

上一篇:Unity中 Plugin 跨语言 类型转换(unity跨脚本调用函数)

下一篇:Slider控件、Scrollbar控件、ScrollView控件、Window窗口、GUISkin控件样式(scrollpane.setviewportview)

免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

鄂ICP备2023003026号

网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

友情链接: 武汉网站建设 电脑维修 湖南楚通运网络