HAARFTE/Assets/DemoGame/GameScript/Hotfix/Other/TriggerEvent.cs

24 lines
485 B
C#
Raw Normal View History

2024-11-28 23:50:38 +08:00
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)
{
this.callback = callback;
}
}
}