public class Lesson3 : MonoBehaviour
{
private bool isSel;
public GUIStyle style;
private int nowSel = 1;
private void OnGUI()
{
//多选框
//普通样式
//第二个参数是是否选中,需要在外面申明一个bool配合使用
isSel = GUI.Toggle(new Rect(0, 0, 100, 30), isSel, "Switch");
//自定义样式
//修改固定宽高 FixedWidth和fixedHeight
//修改固定宽高 修改图片的宽高而不影响鼠标响应的区域
//修改从GUIStyle边缘到内容起始处的空间 padding
//padding改变图片和文字显示重叠的问题
//Toggle需要更改On Normal On Hover等属性
isSel = GUI.Toggle(new Rect(0, 0, 100, 30), isSel, "Switch",style);
//单选框是基于多选框
if (GUI.Toggle(new Rect(0, 60, 100, 30), nowSel == 1, "选项一"))
{
nowSel = 1;
}
if(GUI.Toggle(new Rect(0, 60, 100, 30), nowSel == 2, "选项一"))
{
nowSel = 2;
}
if(GUI.Toggle(new Rect(0, 60, 100, 30), nowSel == 3, "选项一"))
{
nowSel = 3;
}
}
}