#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.BindWithState(visualEffect, name, static (x, target, n) =>
{
target.SetFloat(n, 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.BindWithState(visualEffect, (x, target) =>
{
target.SetFloat(nameID, 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.BindWithState(visualEffect, name, static (x, target, n) =>
{
target.SetInt(n, 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.BindWithState(visualEffect, (x, target) =>
{
target.SetFloat(nameID, 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.BindWithState(visualEffect, name, static (x, target, n) =>
{
target.SetVector2(n, 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.BindWithState(visualEffect, (x, target) =>
{
target.SetVector2(nameID, 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.BindWithState(visualEffect, name, static (x, target, n) =>
{
target.SetVector3(n, 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.BindWithState(visualEffect, (x, target) =>
{
target.SetVector3(nameID, 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.BindWithState(visualEffect, name, static (x, target, n) =>
{
target.SetVector4(n, 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.BindWithState(visualEffect, (x, target) =>
{
target.SetVector4(nameID, x);
});
}
}
}
#endif