using UnityEngine;
namespace LitMotion.Extensions
{
///
/// Provides binding extension methods for Material.
///
public static class LitMotionMaterialExtensions
{
///
/// Create a motion data and bind it to a material property.
///
/// 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 BindToMaterialFloat(this MotionBuilder builder, Material material, string name)
where TOptions : unmanaged, IMotionOptions
where TAdapter : unmanaged, IMotionAdapter
{
Error.IsNull(material);
return builder.BindWithState(material, name, static (x, m, n) =>
{
m.SetFloat(n, x);
});
}
///
/// Create a motion data and bind it to a material property.
///
/// 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 BindToMaterialFloat(this MotionBuilder builder, Material material, int nameID)
where TOptions : unmanaged, IMotionOptions
where TAdapter : unmanaged, IMotionAdapter
{
Error.IsNull(material);
return builder.BindWithState(material, (x, m) =>
{
m.SetFloat(nameID, x);
});
}
///
/// Create a motion data and bind it to a material property.
///
/// 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 BindToMaterialInt(this MotionBuilder builder, Material material, string name)
where TOptions : unmanaged, IMotionOptions
where TAdapter : unmanaged, IMotionAdapter
{
Error.IsNull(material);
return builder.BindWithState(material, name, static (x, m, n) =>
{
m.SetInteger(n, x);
});
}
///
/// Create a motion data and bind it to a material property.
///
/// 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 BindToMaterialInt(this MotionBuilder builder, Material material, int nameID)
where TOptions : unmanaged, IMotionOptions
where TAdapter : unmanaged, IMotionAdapter
{
Error.IsNull(material);
return builder.BindWithState(material, (x, m) =>
{
m.SetInteger(nameID, x);
});
}
///
/// Create a motion data and bind it to a material property.
///
/// 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 BindToMaterialColor(this MotionBuilder builder, Material material, string name)
where TOptions : unmanaged, IMotionOptions
where TAdapter : unmanaged, IMotionAdapter
{
Error.IsNull(material);
return builder.BindWithState(material, name, static (x, m, n) =>
{
m.SetColor(n, x);
});
}
///
/// Create a motion data and bind it to a material property.
///
/// 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 BindToMaterialColor(this MotionBuilder builder, Material material, int nameID)
where TOptions : unmanaged, IMotionOptions
where TAdapter : unmanaged, IMotionAdapter
{
Error.IsNull(material);
return builder.BindWithState(material, (x, m) =>
{
m.SetColor(nameID, x);
});
}
}
}