Tri-Inspector/Editor/TriValue.cs

43 lines
886 B
C#
Raw Normal View History

2022-05-11 04:23:11 -04:00
using System;
using JetBrains.Annotations;
namespace TriInspector
2021-12-07 10:20:36 -05:00
{
2022-01-21 23:36:15 -05:00
public struct TriValue<T>
2021-12-07 10:20:36 -05:00
{
internal TriValue(TriProperty property)
{
Property = property;
}
public TriProperty Property { get; }
2022-05-11 04:23:11 -04:00
[Obsolete("Use SmartValue instead", true)]
2021-12-07 10:20:36 -05:00
public T Value
{
get => (T) Property.Value;
set => Property.SetValue(value);
}
2022-05-11 04:23:11 -04:00
[PublicAPI]
public T SmartValue
{
get => (T) Property.Value;
set
{
2022-07-12 06:09:21 -04:00
if (Property.Comparer.Equals(Property.Value, value))
2022-05-11 04:23:11 -04:00
{
return;
}
Property.SetValue(value);
}
}
[PublicAPI]
public void SetValue(T value)
{
Property.SetValue(value);
}
2021-12-07 10:20:36 -05:00
}
}