41 lines
1.4 KiB
C#
41 lines
1.4 KiB
C#
![]() |
using UnityEngine;
|
|||
|
|
|||
|
namespace Plugins.Animate_UI_Materials
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// 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
|
|||
|
/// </summary>
|
|||
|
[AddComponentMenu("UI/Animate UI Material/GraphicPropertyOverrideColor")]
|
|||
|
public class GraphicPropertyOverrideColor : GraphicPropertyOverride<Color>
|
|||
|
{
|
|||
|
#if UNITY_EDITOR
|
|||
|
/// <summary>
|
|||
|
/// A flag for the editor to draw the color field as HDR
|
|||
|
/// </summary>
|
|||
|
public bool isHDR;
|
|||
|
#endif
|
|||
|
/// <summary>
|
|||
|
/// Apply the modified property to the material
|
|||
|
/// </summary>
|
|||
|
/// <param name="material"></param>
|
|||
|
public override void ApplyModifiedProperty(Material material)
|
|||
|
{
|
|||
|
material.SetColor(PropertyId, propertyValue);
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// Retrieve the default Color value from the source material
|
|||
|
/// </summary>
|
|||
|
/// <param name="material">The source material</param>
|
|||
|
/// <param name="defaultValue">The Color value from the material</param>
|
|||
|
/// <returns>True if the value could be retrieved</returns>
|
|||
|
public override bool GetDefaultValue(Material material, out Color defaultValue)
|
|||
|
{
|
|||
|
bool hasProperty = material.HasColor(PropertyId);
|
|||
|
defaultValue = hasProperty ? material.GetColor(PropertyId) : default;
|
|||
|
return hasProperty;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|