vexe / VFW

MIT License
492 stars 67 forks source link

Callback on array length change in editor #21

Closed YacineFenina closed 9 years ago

YacineFenina commented 9 years ago

Hello !

Thank you for your work! That is really awesome ! I would like to know if there is a way to have an "OnChanged" when length of an array instead of the item modification (or a List) is modified ?

Edit : Actually I'm searching, and my real question is : Am I doing it well Maybe I can extend ListDrawer and call a delegate in right function ? And add it to the TypeDrawerMapper ? Is it a good way ?

Thanks in advance !

vexe commented 9 years ago

You can use 'OnChanged' (See OnChangedExample.cs) - I tried it, it gave me notification when an array count changed, but not a list. So I did some modifications to make it work. See https://github.com/vexe/VFW/commit/4fedb85d33f4cd7a77a8710d56fb49b86d3c27b7 and https://github.com/vexe/VFW/commit/55a4b0ade5c23aa0f6c7f32583ba3e9979d4aea9

This should now work:

[OnChanged("OnListChanged")
public List<GameObject> testList;

[OnChanged("OnArrayChanged")]
public GameObject[] testArray;

void OnListChanged(List<GameObject> list)
{
    Log(list.Count);
}

void OnArrayChanged(GameObject[] array)
{
    Log(array.Length);
}