enum in inspector?

I used this http://wiki.unity3d.com/index.php/ExposePropertiesInInspector_Generic
for a bool and it worked fine, but when I used it on an enum it gave weird result.
Code:

public enum TileDirection
{
    Right,
    Left,
    Top,
    Bottom
}

[ExposeProperty]
public TileDirection Direction
{
    set
    {
        direction = value;
        Debug.Log(direction);

    }
    get { return direction; }
}
[HideInInspector, SerializeField]
private TileDirection direction;

when I changed from Bottom to Right I got this:

79225-weird.png

Am I doing something wrong?

The problem is most likely that the condition in this line:

if (oldValue != newValue)

will always evaluate to “true” for enum values as the “Enum” type is a class type. So the value will be boxed and comparing boxed values will compare the references and not the actual values.

To fix this issue you would have to change the way how you compare the values inside the “Expose” method:

if (oldValue != null && oldValue.Equals(newValue))
    field.SetValue(newValue);

tack on “.ToString()”.

eg:

Debug.Log(direction.ToString());