codewriter-packages / Tri-Inspector

Free inspector attributes for Unity [Custom Editor, Custom Inspector, Inspector Attributes, Attribute Extensions]
MIT License
972 stars 47 forks source link

Serialized property bug #151

Closed ese9 closed 9 months ago

ese9 commented 9 months ago

Describe the bug

For serialized properties changing fields with reference types (AnimationCurve, Gradient) doesn't mark object as dirty

Expected behavior After changing values object marks as dirty

Code Sample

Changing values inside testField works as intended, but not for TestProperty

public class CurveTest : MonoBehaviour
{
    public NestedReferenceTest testField;

    [ShowInInspector]
    [InlineProperty]
    [HideLabel]
    [PropertySpace]
    public NestedReferenceTest TestProperty
    {
        get => testField;
        set => testField = value;
    }
}

[Serializable]
public class NestedReferenceTest
{
    public AnimationCurve curve;
    public Gradient gradient;
    public float floatValue;
}

The problem is in the TriValue.SmartValue I suppose - comparer for reference values always returns true

        [PublicAPI]
        public T SmartValue
        {
            get => (T) Property.Value;
            set
            {
                if (Property.Comparer.Equals(Property.Value, value))
                {
                    return;
                }

                Property.SetValue(value);
            }
        }

Desktop: Windows 10 Unity version: 2022.3.16f1 Tri Inspector version: 1.13.2