public class Lesson2 : MonoBehaviour
{
public Texture guiT;
public Rect rect;
public Rect rect1;
public GUIContent content;
public GUIStyle guiS;
public Rect btnRect;
public GUIContent btncontent;
public GUIStyle btnstyle;
private void OnGUI()
{
#region GUI控件绘制的共同点
//都是GUI公共类中提供的静态函数,直接调用即可
#endregion
#region 文本控件
//基本使用
//GUI的原点是左上角
//Rect(x位置,y位置,width尺寸,height尺寸)
//会保持图片的原始宽高比
GUI.Label(new Rect(0, 0, 100, 20), "Admin");
GUI.Label(rect,guiT);
//综合使用
GUI.Label(rect1,content);
//获取鼠标或键盘当前选中的GUI控件的tooltip
Debug.Log(GUI.tooltip);
//自定义样式
GUI.Label(new Rect(20, 20, 100, 20), "Admin",guiS);
#endregion
#region 按钮控件
//GUI.Button(btnRect,btncontent,btnstyle);
//检测点击
//按下抬起才算一次点击
if(GUI.Button(btnRect, btncontent, btnstyle))
{
Debug.Log("Clicked");
}
//按住会一直检测
if (GUI.RepeatButton(btnRect, btncontent))
{
Debug.Log("LongClicked");
}
#endregion
}
}