Files
kaiju/Assets/ThemeVfxBinder.cs

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 Preferences preferences;
[VFXPropertyBinding("UnityEngine.Gradient"), SerializeField]
protected ExposedProperty ThemeParameter = "Theme";
void Awake() {
if (preferences == null) Debug.Log("Theme VFX Binder needs preferences.");
}
public override bool IsValid(VisualEffect component) {
return preferences != null
&& preferences.Theme() != null
&& component.HasGradient(ThemeParameter);
}
public override void UpdateBinding(VisualEffect component) {
component.SetGradient(ThemeParameter, preferences.Theme());
}
// have to override these to prevent NRE
protected override void OnEnable() {
// Debug.Log("OnEnable");
}
protected override void OnDisable() {
// Debug.Log("OnDisable");
}
}