#if LITMOTION_SUPPORT_VFX_GRAPH using UnityEngine; using UnityEngine.VFX; namespace LitMotion.Extensions { /// /// Provides binding extension methods for VisualEffect. /// public static class LitMotionVisualEffectExtensions { /// /// Create a motion data and bind it to VisualEffect parameter. /// /// The type of special parameters given to the motion data /// The type of adapter that support value animation /// This builder /// /// Handle of the created motion data. public static MotionHandle BindToVisualEffectFloat(this MotionBuilder builder, VisualEffect visualEffect, string name) where TOptions : unmanaged, IMotionOptions where TAdapter : unmanaged, IMotionAdapter { Error.IsNull(visualEffect); return builder.Bind(visualEffect, name, static (x, visualEffect, name) => { visualEffect.SetFloat(name, x); }); } /// /// Create a motion data and bind it to VisualEffect parameter. /// /// The type of special parameters given to the motion data /// The type of adapter that support value animation /// This builder /// /// Handle of the created motion data. public static MotionHandle BindToVisualEffectFloat(this MotionBuilder builder, VisualEffect visualEffect, int nameID) where TOptions : unmanaged, IMotionOptions where TAdapter : unmanaged, IMotionAdapter { Error.IsNull(visualEffect); return builder.Bind(visualEffect, Box.Create(nameID), static (x, visualEffect, nameID) => { visualEffect.SetFloat(nameID.Value, x); }); } /// /// Create a motion data and bind it to VisualEffect parameter. /// /// The type of special parameters given to the motion data /// The type of adapter that support value animation /// This builder /// /// Handle of the created motion data. public static MotionHandle BindToVisualEffectInt(this MotionBuilder builder, VisualEffect visualEffect, string name) where TOptions : unmanaged, IMotionOptions where TAdapter : unmanaged, IMotionAdapter { Error.IsNull(visualEffect); return builder.Bind(visualEffect, name, static (x, visualEffect, name) => { visualEffect.SetInt(name, x); }); } /// /// Create a motion data and bind it to VisualEffect parameter. /// /// The type of special parameters given to the motion data /// The type of adapter that support value animation /// This builder /// /// Handle of the created motion data. public static MotionHandle BindToVisualEffectInt(this MotionBuilder builder, VisualEffect visualEffect, int nameID) where TOptions : unmanaged, IMotionOptions where TAdapter : unmanaged, IMotionAdapter { Error.IsNull(visualEffect); return builder.Bind(visualEffect, Box.Create(nameID), static (x, visualEffect, nameID) => { visualEffect.SetFloat(nameID.Value, x); }); } /// /// Create a motion data and bind it to VisualEffect parameter. /// /// The type of special parameters given to the motion data /// The type of adapter that support value animation /// This builder /// /// Handle of the created motion data. public static MotionHandle BindToVisualEffectVector2(this MotionBuilder builder, VisualEffect visualEffect, string name) where TOptions : unmanaged, IMotionOptions where TAdapter : unmanaged, IMotionAdapter { Error.IsNull(visualEffect); return builder.Bind(visualEffect, name, static (x, visualEffect, name) => { visualEffect.SetVector2(name, x); }); } /// /// Create a motion data and bind it to VisualEffect parameter. /// /// The type of special parameters given to the motion data /// The type of adapter that support value animation /// This builder /// /// Handle of the created motion data. public static MotionHandle BindToVisualEffectVector2(this MotionBuilder builder, VisualEffect visualEffect, int nameID) where TOptions : unmanaged, IMotionOptions where TAdapter : unmanaged, IMotionAdapter { Error.IsNull(visualEffect); return builder.Bind(visualEffect, Box.Create(nameID), static (x, visualEffect, nameID) => { visualEffect.SetVector2(nameID.Value, x); }); } /// /// Create a motion data and bind it to VisualEffect parameter. /// /// The type of special parameters given to the motion data /// The type of adapter that support value animation /// This builder /// /// Handle of the created motion data. public static MotionHandle BindToVisualEffectVector3(this MotionBuilder builder, VisualEffect visualEffect, string name) where TOptions : unmanaged, IMotionOptions where TAdapter : unmanaged, IMotionAdapter { Error.IsNull(visualEffect); return builder.Bind(visualEffect, name, static (x, visualEffect, name) => { visualEffect.SetVector3(name, x); }); } /// /// Create a motion data and bind it to VisualEffect parameter. /// /// The type of special parameters given to the motion data /// The type of adapter that support value animation /// This builder /// /// Handle of the created motion data. public static MotionHandle BindToVisualEffectVector3(this MotionBuilder builder, VisualEffect visualEffect, int nameID) where TOptions : unmanaged, IMotionOptions where TAdapter : unmanaged, IMotionAdapter { Error.IsNull(visualEffect); return builder.Bind(visualEffect, Box.Create(nameID), static (x, visualEffect, nameID) => { visualEffect.SetVector3(nameID.Value, x); }); } /// /// Create a motion data and bind it to VisualEffect parameter. /// /// The type of special parameters given to the motion data /// The type of adapter that support value animation /// This builder /// /// Handle of the created motion data. public static MotionHandle BindToVisualEffectVector4(this MotionBuilder builder, VisualEffect visualEffect, string name) where TOptions : unmanaged, IMotionOptions where TAdapter : unmanaged, IMotionAdapter { Error.IsNull(visualEffect); return builder.Bind(visualEffect, name, static (x, visualEffect, name) => { visualEffect.SetVector4(name, x); }); } /// /// Create a motion data and bind it to VisualEffect parameter. /// /// The type of special parameters given to the motion data /// The type of adapter that support value animation /// This builder /// /// Handle of the created motion data. public static MotionHandle BindToVisualEffectVector4(this MotionBuilder builder, VisualEffect visualEffect, int nameID) where TOptions : unmanaged, IMotionOptions where TAdapter : unmanaged, IMotionAdapter { Error.IsNull(visualEffect); return builder.Bind(visualEffect, Box.Create(nameID), static (x, visualEffect, nameID) => { visualEffect.SetVector4(nameID.Value, x); }); } } } #endif