0

我正在使用此脚本在完成时销毁游戏对象,但它不起作用。

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);
}

有谁知道为什么这不起作用?

4

1 回答 1

1

从我看到你的脚本没有附加到currentCube你试图调用DestroyOnCompletedon 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
    )
);
于 2017-07-26T11:17:15.493 回答