Skip to content

Commit

Permalink
fix: GradientField notify on value changed
Browse files Browse the repository at this point in the history
  • Loading branch information
fuqunaga committed Feb 26, 2024
1 parent 7013df6 commit 284601b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,38 @@ public class GradientField : BaseField<Gradient>

private readonly Background m_DefaultBackground = new();


public override Gradient value
{
get
{
if (_valueNull) return null;

return GradientCopy(rawValue);
}
set
{
if (value != null || !_valueNull) // let's not reinitialize an initialized gradient
{
using (ChangeEvent<Gradient> evt = ChangeEvent<Gradient>.GetPooled(rawValue, value))
{
evt.target = this;
SetValueWithoutNotify(value);
SendEvent(evt);
}
}
}
}

internal static Gradient GradientCopy(Gradient other)
{
Gradient gradientCopy = new Gradient();
gradientCopy.colorKeys = other.colorKeys;
gradientCopy.alphaKeys = other.alphaKeys;
gradientCopy.mode = other.mode;
return gradientCopy;
}

/// <summary>
/// Constructor.
/// </summary>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 284601b

Please sign in to comment.