Odd behaviour when invoking setter-style methods

Issue #456 new
Marko Bakšić created an issue

Hi guys, I've found some odd behaviour regarding invoking setter style methods.

using Sirenix.OdinInspector;

public class OdinBugDemo : SerializedMonoBehaviour
{
    [Button, PropertyOrder(int.MinValue)]
    public void SetObject(SomeType newObject)
    {
        someObject = newObject;
    }

    public SomeType someObject;

    [Button, PropertyOrder(int.MaxValue)]
    public void SetObject2(SomeType newObject)
    {
        someObject = newObject;
    }
}

public class SomeType
{
    public int a = 6;
}

There are two different odd behaviours here. Both come into play when there is a method that sets a field. Different oddities occour depending on whether the method is drawn before or after the field. Fig. 1 shows the inspector for the above class.

Method before the field:
If I set the parameter of the method to a new SomeType and invoke the method, then the field breaks and shows an error (fig. 2). If I then set the parameter of the method to null, the field displays the correct value (fig. 3).

Method after the field:
If I set the parameter of the method to a new SomeType and invoke the method, then the parameter references the field (maybe? I don't really know), and the parameter can't be changed anymore (fig. 4).


Unity version: 2018.2.11f1
Odin version: 2.0.6
Windows 10

Comments (1)

  1. Log in to comment