using UnityEngine; using System.Collections; public class Gui : MonoBehaviour { public Texture2D buttonTexture; private string str; private int frameTime; // Use this for initialization void Start () { str="请您点击按钮"; } // Update is called once per frame void Update () { } void OnGUI() { GUI.Label (new Rect (10, 10, Screen.width, 30), str); if (GUI.Button (new Rect (10, 50, buttonTexture.width, buttonTexture.height), buttonTexture)) { str="您点击了图片按钮"; } GUI.color = Color.green; GUI.backgroundColor = Color.red; if (GUI.Button (new Rect (10, 400, 70, 30), "文字按钮")) { str="您点击了文字按钮"; } GUI.color = Color.yellow; GUI.backgroundColor = Color.black; if (GUI.RepeatButton (new Rect (10, 500, 100, 30), "按钮按下中")) { str=frameTime+""; frameTime++; } } }