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的宽和高