- 最后登录
- 2016-8-29
- 注册时间
- 2012-8-25
- 阅读权限
- 90
- 积分
- 23585
  
- 纳金币
- 20645
- 精华
- 62
|
可以说协程是一个至关重要的功能,大部分牵涉到过程和延迟处理的时候都需要用到,下面是一个临时关闭脚本的原理代码:
void OnTriggerEnter(Collider other)
{
if(other.gameObject.name != "Player") return; //skips the rest of the function if something else entered the trigger besides what we want to actually trigger the event
StartCoroutine(MyCoroutine());
}
IEnumerator MyCoroutine()
{
//disable the desired script here //关闭
yield return new WaitForSeconds(10F);//等待10s
//enable it here//再打开
}
|
|