0
我正在製作一個遊戲,其中我正在使用單擊功能,當我單擊對象時,它上面寫的字母顯示出來,現在我希望當我再次單擊相同的對象時,這個單詞消失..現在我該怎麼做?在unity3D中選擇和取消選擇對象3D
#pragma strict
static var nextPos = 200;
var word: String;
var sel: String;
var isClicked : boolean=false;
var xpos: float = 200;
function OnMouseDown()
{
if (!isClicked) {
isClicked = true;
xpos = nextPos;
nextPos += 8;
}
}
function OnGUI()
{
if (gameObject.name == "Sphere(Clone)" && isClicked)
{
GUI.Label(new Rect(xpos,260,400,100), "A");
}
else if (gameObject.name == "Sphere 1(Clone)" && isClicked)
{
GUI.Label(new Rect(xpos,260,400,100), "B");
}
else if (gameObject.name == "Sphere 2(Clone)" && isClicked)
{
GUI.Label(new Rect(xpos,260,400,100), "C");
}
else if (gameObject.name == "Sphere 3(Clone)" && isClicked)
{
GUI.Label(new Rect(xpos,260,400,100), "D");
}
}
你在哪裏連接這個腳本?即哪個GameObject? – Dasu
with sphere ..., – zahra