using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
///
/// Adds space for a UI/OuterGlowV2 halo WITHOUT scaling the original sprite.
/// Works with a standard UGUI Image of Type = Simple, Use Sprite Mesh = false.
/// Requires a Canvas UV1 channel (enabled automatically below).
///
[ExecuteAlways]
[DisallowMultipleComponent]
[RequireComponent(typeof(Image))]
public sealed class UIOuterGlowMeshPadding : BaseMeshEffect
{
[Min(0f)] public float ExtraPaddingPixels = 4f;
private float _lastRadius = -1f;
private float _lastExtra = -1f;
private Vector2 _lastSize;
private Sprite _lastSprite;
private Material _lastMaterial;
protected override void OnEnable()
{
base.OnEnable();
EnableUv1();
SetDirty();
}
protected override void OnDisable()
{
base.OnDisable();
SetDirty();
}
#if UNITY_EDITOR
protected override void OnValidate()
{
base.OnValidate();
ExtraPaddingPixels = Mathf.Max(0, ExtraPaddingPixels);
EnableUv1();
SetDirty();
}
#endif
private void SetDirty()
{
if (graphic != null)
graphic.SetVerticesDirty();
}
private void EnableUv1()
{
Canvas canvas = GetComponentInParent