43 lines
1.3 KiB
C#
Raw Normal View History

2020-03-02 02:26:06 +01:00
using UnityEngine;
using UnityAtoms.BaseAtoms;
2019-10-16 01:43:51 +02:00
2020-03-02 02:26:06 +01:00
namespace UnityAtoms.MonoHooks
{
/// <summary>
/// Base class for all `MonoHook`s of type `Collider`.
/// </summary>
[EditorIcon("atom-icon-delicate")]
public abstract class ColliderHook : MonoHook<
ColliderEvent,
Collider,
2020-03-02 19:52:08 +01:00
ColliderEventReference,
2020-03-02 02:26:06 +01:00
GameObjectGameObjectFunction>
{
/// <summary>
/// Event including a GameObject reference.
/// </summary>
2020-03-02 19:52:08 +01:00
public ColliderGameObjectEvent EventWithGameObject
{
get => _eventWithGameObjectReference != null ? _eventWithGameObjectReference.GetEvent<ColliderGameObjectEvent>() : null;
set
{
if (_eventWithGameObjectReference != null)
{
_eventWithGameObjectReference.SetEvent<ColliderGameObjectEvent>(value);
}
}
}
2020-03-02 02:26:06 +01:00
[SerializeField]
2020-03-02 20:27:38 +01:00
private ColliderGameObjectEventReference _eventWithGameObjectReference = default(ColliderGameObjectEventReference);
2020-03-02 02:26:06 +01:00
protected override void RaiseWithGameObject(Collider value, GameObject gameObject)
{
2020-03-02 19:52:08 +01:00
if (EventWithGameObject)
2020-03-02 19:36:52 +01:00
{
2020-03-02 19:52:08 +01:00
EventWithGameObject.Raise(new ColliderGameObject() { Collider = value, GameObject = gameObject });
2020-03-02 19:36:52 +01:00
}
2020-03-02 02:26:06 +01:00
}
}
}