using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.VFX;
namespace UnityEngine.VFX.Utility
{
///
/// Base Class to derive in order to Write Visual Effect Binders
///
[ExecuteAlways, RequireComponent(typeof(VFXPropertyBinder))]
public abstract class VFXBinderBase : MonoBehaviour
{
///
/// VFXPropertyBinder master behaviour this binder is attached to.
///
protected VFXPropertyBinder binder;
///
/// Implement this method to perform validity checks:
/// - Visual Effect Implements correct Properties
/// - Objects to get values from are correctly set
///
/// the Visual Effect Componnent to bind properties to
/// Whether the binding can be performed
public abstract bool IsValid(VisualEffect component);
///
/// Optional method allowing potential manual state reset of binder
///
public virtual void Reset()
{
}
///
/// Awake Message : gets the master VFX Property Binder from this game object.
///
protected virtual void Awake()
{
binder = GetComponent();
}
///
/// OnEnable Message : Adds this binding in the VFXPropertyBinder update loop
///
protected virtual void OnEnable()
{
if (!binder.m_Bindings.Contains(this))
binder.m_Bindings.Add(this);
hideFlags = HideFlags.HideInInspector; // Comment to debug
}
///
/// OnEnable Message : Removes this binding from the VFXPropertyBinder update loop
///
protected virtual void OnDisable()
{
if (binder.m_Bindings.Contains(this))
binder.m_Bindings.Remove(this);
}
///
/// Implement UpdateBinding to perform the actual binding. This method is called by the VFXPropertyBinder if IsValid() returns true;
///
/// The VisualEffect component to bind to
public abstract void UpdateBinding(VisualEffect component);
///
/// Returns a readable string summary of this Binder.
///
/// a readable string summary of this Binder
public override string ToString()
{
return GetType().ToString();
}
}
}