ドキュメント

Unity Engine

Unity Engine

PropertyCollectionAttribute

Base class to derive custom property attributes for collections from. Use this to create custom attributes for array and list variables in scripts.
読み終わるまでの所要時間 4 分最終更新 1ヶ月前

Definition

注意
Deprecated. Derive collection attributes from 'PropertyAttribute' and set its 'applyToCollection' property to 'true'.
[AttributeUsage(AttributeTargets.Field, Inherited = true, AllowMultiple = false)]public abstract class PropertyCollectionAttribute : PropertyAttribute

Remarks

A custom attributes can be hooked up with a custom PropertyDrawer class to control how a script variable with that attribute is shown in the Inspector.
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 : PropertyCollectionAttribute { }[CustomPropertyDrawer(typeof(GreenCollectionDrawerAttribute))]public class GreenCollectionDrawer : PropertyDrawer{ public override VisualElement CreatePropertyGUI(SerializedProperty property) { return new PropertyField(property) { style = { backgroundColor = Color.green } }; }}
Additional Resources: PropertyDrawer class.

Inheritance

Inherited Members