Files
kaiju/Assets/ThemeVfxBinder.cs
T
2022-03-31 18:10:08 +11:00

40 lines
1.1 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
using UnityEngine.VFX.Utility;
using UnityEngine.VFX;
using UnityEngine;
[AddComponentMenu("VFX/Property Binders/Kaiju - Theme Binder")]
[VFXBinder("Kaiju/Kaiju Theme Binder")]
public class ThemeVfxBinder : VFXBinderBase {
public ThemeSelector themeSelector;
[VFXPropertyBinding("UnityEngine.Gradient"), SerializeField]
protected ExposedProperty ThemeParameter = "Theme";
void Awake() {
if (themeSelector == null) Debug.Log("Theme VFX Binder needs theme selector.");
}
public override bool IsValid(VisualEffect component) {
return themeSelector != null
&& themeSelector.CurrentTheme() != null
&& component.HasGradient(ThemeParameter);
}
public override void UpdateBinding(VisualEffect component) {
component.SetGradient(ThemeParameter, themeSelector.CurrentTheme());
}
// have to override these to prevent NRE
protected override void OnEnable() {
// Debug.Log("OnEnable");
}
protected override void OnDisable() {
// Debug.Log("OnDisable");
}
}