using UnityEditor;
using UnityEngine;

namespace Plugins.Animate_UI_Materials.Editor
{
  using PropertyType = ShaderUtil.ShaderPropertyType;

  /// <summary>
  /// A special editor for Color properties
  /// Retrieves the hdr flag from the property override
  /// </summary>
  [CustomEditor(typeof(GraphicPropertyOverrideColor), true)]
  public class GraphicPropertyOverrideColorEditor : GraphicPropertyOverrideEditor
  {
    protected override void DrawValueProperty(SerializedProperty property)
    {
      // If in multi-edit mode, just display a color field
      if (targets.Length > 1 || target is not GraphicPropertyOverrideColor propertyOverride)
      {
        base.DrawValueProperty(property);
        return;
      }

      Material material = GetTargetMaterial();

      GraphicMaterialOverrideEditor.DrawColorPropertyAsHdr(
        material,
        property,
        propertyOverride.isHDR,
        new GUIContent(""));
    }
  }
}