unity-actions-example/Assets/Scripts/OnCollisionEnterEvent.cs
2020-10-08 10:26:37 -04:00

21 lines
502 B
C#

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Serialization;
public class OnCollisionEnterEvent : MonoBehaviour
{
[SerializeField] private UnityEvent @event;
[SerializeField] private string otherGameObjectName = "Sphere";
private void OnCollisionEnter(Collision other)
{
if (other.gameObject.name == otherGameObjectName)
{
@event.Invoke();
}
}
}