Unity中创建并列的button按钮 | 您所在的位置:网站首页 › unityapply按钮 › Unity中创建并列的button按钮 |
Unity中创建并列的button按钮
发表于2018-05-06
评论0
1.4k浏览
想免费获取内部独家PPT资料库?观看行业大牛直播?点击加入腾讯游戏学堂游戏程序行业精英群 711501594 button按钮可以算是用的最多的按钮之一,如果想创建并列的button按钮怎么办?下面就和大家分享下创建的方法。直接上代码: using System.Collections; using System.Collections.Generic; using UnityEngine; public class ButtonStyle : MonoBehaviour { //public Color _color; // //public Texture2D tex; public int x1 = 0; public int y1 = 0; public int y2 = 100; public int x2 = 100; void OnGUI(){ for (int i = 0; i < 2; i++) { for (int j = 0; j < 5; j++) { GUI.Button (new Rect (x1 + 105 * j, y1 + 105 * i, x2, y2), "tex" +i+""+j); } } // GUI.Button(new Rect(0,0,100,100),"tex"); // Color oldColor = GUI.backgroundColor;//保存原有的背景色 // GUI.backgroundColor = _color;//更改背景色 // GUI.Button (new Rect (650,20,150,120), tex);//这个按钮的背景色发生了变化 GUI.backgroundColor = oldColor;//恢复原来的背景色 // GUI.Button(new Rect(140,100,100,100),"tex1");//这个按钮恢复了以前的背景色 } } public Rect (float x, float y, float width, float height);方法中的四个参数 x,y坐标,即button中左上角的坐标,wight,height 是button的宽和高。原文链接 著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。 如社区发表内容存在侵权行为,您可以点击这里查看侵权投诉指引 标签: UnityJavaScript本文作者 feng 暂无简介 Mesh绘制交互网格 Unity基本介绍与使用 Unity使用RenderTexture实现实时阴影绘制 Unity3D AsssetBundle加载效率比较 Unity发布WebGL时如何修改、删除默认的载入进度条 GWB公众号 腾讯游戏学堂公众号 |
CopyRight 2018-2019 实验室设备网 版权所有 |