使属性影响集合而不是其项目。
using UnityEditor; using UnityEditor.UIElements; using UnityEngine; using UnityEngine.UIElements;
public class Collection : MonoBehaviour { public int before; [GreenCollectionDrawer] public int[] collection; public int after; }
public class GreenCollectionDrawerAttribute : PropertyAttribute { public GreenCollectionDrawerAttribute() : base(true) { } }
[CustomPropertyDrawer(typeof(GreenCollectionDrawerAttribute))] public class GreenCollectionDrawer : PropertyDrawer { public override VisualElement CreatePropertyGUI(SerializedProperty property) { return new PropertyField(property) { style = { backgroundColor = Color.green } }; } }