48 lines
803 B
C#
48 lines
803 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class TriggerActive_control : MonoBehaviour
|
|
{
|
|
public GameObject 触发物体;
|
|
public bool 是否只执行一次;
|
|
private bool first=true;
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
private void OnTriggerEnter(Collider other)
|
|
{
|
|
if (first == false)
|
|
return;
|
|
触发物体.SetActive(true);
|
|
first = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
private void OnTriggerExit(Collider other)
|
|
{
|
|
|
|
触发物体.SetActive(false);
|
|
if (是否只执行一次 == false)
|
|
{
|
|
|
|
first = true;
|
|
|
|
|
|
}
|
|
}
|
|
}
|