25 lines
543 B
C#
25 lines
543 B
C#
using System;
|
|
using UnityEngine;
|
|
|
|
namespace ZC
|
|
{
|
|
public class TriggerEvent : MonoBehaviour
|
|
{
|
|
[SerializeField] private string targetName;
|
|
private Action callback;
|
|
|
|
private void OnTriggerEnter(Collider other)
|
|
{
|
|
if (other.name == targetName)
|
|
{
|
|
callback?.Invoke();
|
|
}
|
|
}
|
|
|
|
public void SetData(Action callback, string target = "Player")
|
|
{
|
|
this.targetName = target;
|
|
this.callback = callback;
|
|
}
|
|
}
|
|
} |