1.GUI(手动布局GUI、自动布局GUILayout、皮肤设置)
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GUIDemo : MonoBehaviour
{
[Header("显示GUI")]
public bool showGUI = true;
[Header("皮肤设置文件")]
public GUISkin Skin;
private string textFieldText = "wodemima";
private float sliderValue = 10;
private void OnGUI()
{
//设置皮肤
GUI.skin = Skin;
#region GUI
//手动布局
if (showGUI)
{
//按钮
bool click = GUI.Button(new Rect(100, 100,
200, 50), "登录按钮");
if (click)
{
Debug.Log("点击了登录按钮...");
}
if (GUI.Button(new Rect(100,300,200,50),"注册按钮" ))
{
Debug.Log("点击了注册按钮...");
}
//文本
GUI.Label(new Rect(100,400,100,100),"登录成功!" );
//输入框
textFieldText = GUI.TextField(new Rect(100, 500, 200, 50), textFieldText);
//滑动条
sliderValue = GUI.HorizontalSlider(new Rect(100, 600, 300, 50), sliderValue, 0, 100);
}
#endregion
#region GUILayout
//自动布局
else
{
//按钮
if (GUILayout.Button("购买皮肤"))
{
Debug.Log("购买成功!");
}
//文本
textFieldText = GUILayout.TextField(textFieldText);
}
#endregion
}
}
2.NGUI插件
3.UGUI
位置 Rect Tansform
文字Text
图片Image
Raw Image
可交互UI: