统一。 一段时间后的函数调用

如何在一段时间后使对象不可见(或只是删除)? 使用NGUI。

我的例子(改变):

public class scriptFlashingPressStart : MonoBehaviour { public GameObject off_Logo; public float dead_logo = 1.5f; void OffLogo() { off_Logo.SetActive(false); } //function onclick button //remove item after a certain time after pressing ??? void press_start() { InvokeRepeating("OffLogo", dead_logo , ...); } } 

使用Invoke而不是InvokeRepeating。 在这里检查调用function

  public class scriptFlashingPressStart : MonoBehaviour { public GameObject off_Logo; public float dead_logo = 1.5f; bool pressed = false; void OffLogo() { //do anything(delete or invisible) off_Logo.SetActive(false); pressed = false; } //use Invoke rather than InvokeRepeating void press_start() { if(!pressed) { pressed = true; Invoke("OffLogo", dead_logo); } else { Debug.Log("Button already pressed"); } } } 

尝试

 StartCoroutine(SomeFunctionAfterSomeTime); IEnumerator SomeFunctionAfterSomeTime() { ... //Your own logic yield return new WaitForSeconds(SomeTime); } 

您可以通过简单地调用Destroy来在给定时间内销毁对象。 请参阅http://docs.unity3d.com/Documentation/ScriptReference/Object.Destroy.html