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.
45 lines
1.1 KiB
45 lines
1.1 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine.VFX;
|
|
|
|
namespace UnityEngine.VFX.Utility
|
|
{
|
|
abstract class VFXEventBinderBase : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
protected VisualEffect target;
|
|
public string EventName = "Event";
|
|
|
|
[SerializeField, HideInInspector]
|
|
protected VFXEventAttribute eventAttribute;
|
|
|
|
protected virtual void OnEnable()
|
|
{
|
|
UpdateCacheEventAttribute();
|
|
}
|
|
|
|
private void OnValidate()
|
|
{
|
|
UpdateCacheEventAttribute();
|
|
}
|
|
|
|
private void UpdateCacheEventAttribute()
|
|
{
|
|
if (target != null)
|
|
eventAttribute = target.CreateVFXEventAttribute();
|
|
else
|
|
eventAttribute = null;
|
|
}
|
|
|
|
protected abstract void SetEventAttribute(object[] parameters = null);
|
|
|
|
protected void SendEventToVisualEffect(params object[] parameters)
|
|
{
|
|
if (target != null)
|
|
{
|
|
SetEventAttribute(parameters);
|
|
target.SendEvent(EventName, eventAttribute);
|
|
}
|
|
}
|
|
}
|
|
}
|