最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

unity實(shí)現(xiàn)物體延時(shí)出現(xiàn)

 更新時(shí)間:2021年04月01日 08:35:08   作者:Gyp郭小帥  
這篇文章主要為大家詳細(xì)介紹了unity實(shí)現(xiàn)物體延時(shí)出現(xiàn),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了unity實(shí)現(xiàn)物體延時(shí)出現(xiàn)的具體代碼,供大家參考,具體內(nèi)容如下

新建一個(gè)cube和plane,隱藏cube,腳本掛在plane上。

1. update計(jì)時(shí)器實(shí)現(xiàn)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
 
//一個(gè)隱藏的物體等待t秒后顯示,updata計(jì)時(shí)器實(shí)現(xiàn)
public class activeShow : MonoBehaviour {
 
 public GameObject cube;
 public int t;
 private float m_timer=0;
 
 // Use this for initialization
 void Start () {
 
 }
 
 // Update is called once per frame
 void Update () {
 m_timer+=Time.deltaTime;
 if(m_timer>5){
  cube.SetActive(true);
  m_timer=0;
 }
 }
}

2. invoke實(shí)現(xiàn)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
 
一個(gè)隱藏的物體等待t秒后顯示,Invoke實(shí)現(xiàn)
public class ShowT : MonoBehaviour {
 
 public GameObject cube;
 public int t;//等待時(shí)間
 
 // Use this for initialization
 void Start () {
 Invoke("ActiveShow", t);
 }
 
 // Update is called once per frame
 void Update () {
 
 }
 
 public void ActiveShow(){
 cube.SetActive(true);
 }
}

3. invokeRepeating實(shí)現(xiàn)(這個(gè)是用來湊數(shù)的)

void Start () {
 InvokeRepeating("ActiveShow", t,1000);
 }

4. 協(xié)程實(shí)現(xiàn)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
 
//一個(gè)隱藏的物體等待t秒后顯示,協(xié)程實(shí)現(xiàn)
public class HideInSeconds : MonoBehaviour {
 
 public GameObject cube;
 IEnumerator ie;
 
 // Use this for initialization
 void Start () {
 ie=waitFourSeconds();
 StartCoroutine(ie);
 
 }
 
 // Update is called once per frame
 void Update () {
 
 }
 
 IEnumerator waitFourSeconds(){
 yield return new WaitForSeconds(4.0f);
 cube.SetActive(true);
 }
}

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

普兰县| 兴化市| 大石桥市| 牙克石市| 宁陕县| 阳西县| 仪征市| 高台县| 延寿县| 安平县| 体育| 鞍山市| 阳山县| 呼和浩特市| 台东市| 师宗县| 德阳市| 银川市| 平和县| 麟游县| 兴文县| 曲麻莱县| 桂东县| 榕江县| 乾安县| 孙吴县| 儋州市| 邻水| 六安市| 鱼台县| 凤凰县| 慈利县| 江永县| 永修县| 津市市| 电白县| 博客| 汝州市| 清镇市| 英山县| 雅江县|