revival/game/Assets/Scripts/Util/Events/GameEventTrigger.cs

29 lines
657 B
C#

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
namespace Ktyl.Util
{
[RequireComponent(typeof(BoxCollider))]
public class GameEventTrigger : MonoBehaviour
{
[SerializeField] private GameEvent _event;
[SerializeField] private UnityEvent _raise;
private void Start()
{
GetComponent<BoxCollider>().isTrigger = true;
}
private void OnTriggerEnter(Collider other)
{
if (_event) _event.Raise();
_raise.Invoke();
}
}
}