You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.4 KiB
54 lines
1.4 KiB
#if VFX_HAS_PHYSICS
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
|
|
namespace UnityEngine.VFX.Utility
|
|
{
|
|
[RequireComponent(typeof(Collider))]
|
|
class VFXTriggerEventBinder : VFXEventBinderBase
|
|
{
|
|
public enum Activation
|
|
{
|
|
OnEnter,
|
|
OnExit,
|
|
OnStay
|
|
}
|
|
|
|
public List<Collider> colliders = new List<Collider>();
|
|
|
|
public Activation activation = Activation.OnEnter;
|
|
|
|
private ExposedProperty positionParameter = "position";
|
|
|
|
protected override void SetEventAttribute(object[] parameters)
|
|
{
|
|
Collider collider = (Collider)parameters[0];
|
|
eventAttribute.SetVector3(positionParameter, collider.transform.position);
|
|
}
|
|
|
|
private void OnTriggerEnter(Collider other)
|
|
{
|
|
if (activation != Activation.OnEnter) return;
|
|
if (!colliders.Contains(other)) return;
|
|
|
|
SendEventToVisualEffect(other);
|
|
}
|
|
|
|
private void OnTriggerExit(Collider other)
|
|
{
|
|
if (activation != Activation.OnExit) return;
|
|
if (!colliders.Contains(other)) return;
|
|
|
|
SendEventToVisualEffect(other);
|
|
}
|
|
|
|
private void OnTriggerStay(Collider other)
|
|
{
|
|
if (activation != Activation.OnStay) return;
|
|
if (!colliders.Contains(other)) return;
|
|
|
|
SendEventToVisualEffect(other);
|
|
}
|
|
}
|
|
}
|
|
#endif
|