//文本框内默认有提示,鼠标点击后,提示消失
using UnityEngine;
using System.Collections;
public class BH: MonoBehaviour {
string stringToEdit="stringToEdit";
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if(GUI.GetNameOfFocusedControl()== "XXX"&&stringToEdit=="stringToEdit")
{
stringToEdit="";
}
if(GUI.GetNameOfFocusedControl()!= "XXX"&&stringToEdit=="")
{
print(GUI.GetNameOfFocusedControl());
stringToEdit="stringToEdit";
}
}
void OnGUI(){
GUI.SetNextControlName("XXX");
stringToEdit = GUI.TextField (new Rect (10, 10, 200, 20), stringToEdit, 25);
GUI.TextField(new Rect (10, 50, 200, 20),"");
}
}