最新国产好看的视频,伊人天堂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è)是用來(lái)湊數(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);
 }
}

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

相關(guān)文章

最新評(píng)論

乐安县| 昌乐县| 新野县| 大英县| 陇南市| 攀枝花市| 临西县| 高陵县| 栾川县| 东丽区| 桓台县| 江安县| 女性| 泉州市| 普陀区| 徐州市| 青冈县| 长乐市| 彭山县| 祁连县| 天祝| 肇源县| 绥德县| 北川| 天祝| 洪湖市| 青冈县| 银川市| 扶余县| 黑山县| 宁阳县| 千阳县| 乌海市| 长沙市| 昂仁县| 惠州市| 曲靖市| 白水县| 揭东县| 册亨县| 林西县|