unity3dGUI怎么在特定的时机显示和隐藏绘图?

2025-01-03 01:43:48
推荐回答(2个)
回答1:

bool showLabel=true;
OnGUI ()
{
if(showLabel)
GUI.Label (Rect (0,0,100,50), "Text");

if (GUI.Button (Rect (20,70,80,20), "Level 2"))
{
showLabel=!showLabel
}
}

回答2:

bool showLabel=true; OnGUI () { if(showLabel) GUI.Label (Rect (0,0,100,50), "Text"); if (GUI.Button (Rect (20,70,80,20), "Level 2")) { showLabel=!showLabel } }