unity进入触发器和退出触发器的事件

//分别指图片文本
public GameObject imageKongLong;
public GameObject imageQiang;
void Start () {
}
void Update () {
}
//进入触发器
public void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag == “konglong”)
{
imageKongLong.SetActive(true);
}
if (other.gameObject.tag == “qiang”)
{
imageQiang.SetActive(true);
}
}
//退出触发器
public void OnTriggerExit(Collider other)
{
imageKongLong.SetActive(false);
imageQiang.SetActive(false);
}

猜你喜欢

转载自blog.csdn.net/qq_43024669/article/details/84747253