我正在使用此脚本来破坏游戏对象oncomplete,但它不起作用。
void Jump()
{
if (currentCube.transform.position.y == 0f)
{
iTween.MoveTo (currentCube, iTween.Hash ("y", currentCube.transform.position.y - 15f, "time", 0.8f, "oncomplete", "DestroyOnComplete", "oncompletetarget", currentCube, "easeType", "easeInCubic", "loopType", "none", "delay", 0));
}
}
public void DestroyOnComplete()
{
Destroy (currentCube);
Debug.Log ("Destroyed " + currentCube);
}
有谁知道为什么这不起作用?
答案 0 :(得分:1)
据我所知,您的脚本未附加到currentCube
,而您正试图在DestroyOnCompleted
上调用currentCube
。尝试这样的事情:
iTween.MoveTo (
currentCube,
iTween.Hash (
"y",
currentCube.transform.position.y - 15f,
"time",
0.8f,
"oncomplete",
"DestroyOnComplete",
"oncompletetarget",
gameObject, // here you had `currentCube`, you can even try with `this` instead
"easeType",
"easeInCubic",
"loopType",
"none",
"delay",
0
)
);