统一.一定时间后的函数调用 [英] Unity. Function call after a certain period of time

查看:128
本文介绍了统一.一定时间后的函数调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

How can I make an object invisible (or just delete) after a certain period of time? Use NGUI.

我的示例(用于更改):

My example (for changes):

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. 检查调用函数此处

Use Invoke rather than InvokeRepeating. check Invoke function here

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

这篇关于统一.一定时间后的函数调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆