OnCollectionChanged可以放在集合上,通过inspector更改集合提供事件回调。此外,它提供了CollectionChangeInfo结构,其中包含有关对集合所做的详细更改的信息。但更改其对应Value的内部值是不会进行对应回调的。

image
using Sirenix.OdinInspector;
using Sirenix.OdinInspector.Editor;
using System.Collections.Generic;
using UnityEngine;
public class OnCollectionChangedAttributeExample : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
[InfoBox("更改集合则调用对应的回调,并获取详细更改描述.")]
[OnCollectionChanged("Before", "After")]
public List<string> list = new List