新建C#脚本文件GUITest.cs,写入如下代码
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GUITest : MonoBehaviour
{
public Texture buttonTexture;
public Texture boxTexture;
private string textFieldString = "GUI-TextField";
private string textAreaString = "GUI-TextArea";
private bool toggleValue = false;
private int toolbarInt = 0;
private string[] toolbarStrings = { "Toolbar1", "Toolbar2", "Toolbar3" };
private float hSliderValue = 0.0f;
private float vSliderValue = 0.0f;
private float hScrollbarValue;
private float vScrollbarValue;
private Vector2 scrollViewVector = Vector2.zero;
public void OnGUI()
{
GUI.Label(new Rect(100, 100, 100, 30), "GUI-Label");//文本
GUI.Button(new Rect(100, 140, 100, 30), "GUI-Button");//文本按钮
GUI.Button(new Rect(100, 180, 100,