using UnityEngine;
namespace Plugins.Animate_UI_Materials
{
///
/// Used in with GraphicMaterialOverride to modify a material without creating a variant
/// Added to a child of the Graphic element
/// This variant only applies to Color properties
///
[AddComponentMenu("UI/Animate UI Material/GraphicPropertyOverrideColor")]
public class GraphicPropertyOverrideColor : GraphicPropertyOverride
{
#if UNITY_EDITOR
///
/// A flag for the editor to draw the color field as HDR
///
public bool isHDR;
#endif
///
/// Apply the modified property to the material
///
///
public override void ApplyModifiedProperty(Material material)
{
material.SetColor(PropertyId, propertyValue);
}
///
/// Retrieve the default Color value from the source material
///
/// The source material
/// The Color value from the material
/// True if the value could be retrieved
public override bool GetDefaultValue(Material material, out Color defaultValue)
{
bool hasProperty = material.HasColor(PropertyId);
defaultValue = hasProperty ? material.GetColor(PropertyId) : default;
return hasProperty;
}
}
}