public class Test : MonoBehaviour
{
private string _default = "name";
private string _player_name = "";
private string _tooltip = "player_name_field";
private void OnGUI()
{
GUI.BeginGroup(new Rect(0, 0, 200, 30), new GUIContent("", _tooltip));
_player_name = GUI.TextField(new Rect(0, 0, 200, 30), _player_name);
GUI.EndGroup();
if (UnityEngine.Event.current.type == EventType.Repaint)
{
if (GUI.tooltip == _tooltip)
{
if (_player_name == _default) _player_name = "";
}
else
{
if (_player_name == "") _player_name = _default;
}
}
}
}
see also: http://answers.unity3d.com/questions/215808/clear-textfield-from-default-string.html