function OnTriggerExit (other : Collider) : void
Description描述
OnTriggerExit is called when the Collider other has stopped touching the trigger .
当Collider(碰撞体)停止触发trigger(触发器)时调用OnTriggerExit。
This message is sent to the trigger and the collider that touches the trigger. Note that trigger events are only sent if one of the colliders also has a rigid body attached.
这个消息被发送到触发器和接触到这个触发器的碰撞体。注意如果碰撞体附加了一个刚体,也只发送触发器事件。
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
void OnTriggerExit(Collider other) {
Destroy(other.gameObject);
}
}
// Destroy everything that leaves the trigger
// 销毁所有离开触发器的物体
function OnTriggerExit (other : Collider ) {
Destroy(other.gameObject);
}
OnTriggerExit can be a co-routine, simply use the yield statement in the function.
OnTriggerExit可以被用作协同程序,在函数中调用yield语句。