CollectionDisplayDrawer
The base class all property drawers that display collection values.
- Inheritance:
object -> GUIDrawer -> PropertyDrawer -> PropertyDrawerBase -> CollectionDisplayDrawer
- Namespace:
EditorAttributes.Editor
- Assembly:
EditorAttributes.Editor.asmdef
Syntax:
public abstract class CollectionDisplayDrawer : PropertyDrawerBase
Fields
nullList
A predefined list representing a null collection.
Type: List<string>
Declaration:
protected readonly List<string> nullList = new() { "NULL" };
Methods
CreateDropdownField(List<string>, SerializedProperty)
Creates a dropdown field with all the basic setup for displaying collections.
Declaration:
protected virtual DropdownField CreateDropdownField(List<string> choices, SerializedProperty property)
- Parameters:
List<string>choices: The choices for the dropdownSerializedPropertyproperty: The serialized property this dropdown attaches to
Returns: DropdownField: The dropdown field created
SetDropdownDefaultValue(List<string>, SerializedProperty)
Gets the initial value for when the dropdown is created in the inspector.
Declaration:
protected virtual string SetDropdownDefaultValue(List<string> collectionValues, SerializedProperty property)
- Parameters:
List<string>collectionValues: The collection linked to the dropdownSerializedPropertyproperty: The serialized property attached to the dropdown
Returns: string: The string value set to the dropdown
SetPropertyValueFromDropdown(SerializedProperty, DropdownField)
Sets the value of the property from the dropdown selection.
Declaration:
protected virtual void SetPropertyValueFromDropdown(SerializedProperty property, DropdownField dropdownField)
- Parameters:
SerializedPropertyproperty: The property attached to the dropdownDropdownFielddropdownField: The dropdown field
SetDropdownValueFromProperty(SerializedProperty, DropdownField)
Sets the value of the dropdown from the property value.
Declaration:
protected virtual void SetDropdownValueFromProperty(SerializedProperty trackedProperty, DropdownField dropdownField)
- Parameters:
SerializedPropertytrackedProperty: The property attached to the dropdownDropdownFielddropdownField: The dropdown field
GetDisplayValues(MemberInfo, IDisplayNamesAttribute, SerializedProperty, List<string>)
Gets the display names from the list or dictionary.
Declaration:
protected List<string> GetDisplayValues(MemberInfo collectionInfo, IDisplayNamesAttribute displayNamesAttribute, SerializedProperty serializedProperty, List<string> propertyValues)
- Parameters:
MemberInfocollectionInfo: The member info of the collectionIDisplayNamesAttributedisplayNamesAttribute: The attribute containing the display namesSerializedPropertyserializedProperty: The target propertyList<string>propertyValues: A collection of all property values as a string
Returns: List<string>: A list with the display names
IsCollectionDictionary(MemberInfo, SerializedProperty, out IDictionary)
Checks if a collection is a dictionary.
Declaration:
protected bool IsCollectionDictionary(MemberInfo collectionInfo, SerializedProperty serializedProperty, out IDictionary dictionary)
- Parameters:
MemberInfocollectionInfo: The member info of the collectionSerializedPropertyserializedProperty: The target propertyoutput,
IDictionarydictionary: The collection as a dictionary
Returns: bool: True if the collection is an IDictionary, false otherwise
ConvertCollectionValuesToStrings(string, SerializedProperty, MemberInfo, HelpBox)
Converts the values of a collection into strings.
Declaration:
protected static List<string> ConvertCollectionValuesToStrings(string collectionName, SerializedProperty serializedProperty, MemberInfo memberInfo, HelpBox errorBox)
- Parameters:
stringcollectionName: The name of the collection to convertSerializedPropertyserializedProperty: The serialized propertyMemberInfomemberInfo: The member info of the collectionHelpBoxerrorBox: The error box to display any errors to
Returns: List<string>: The values of the collection in a list of strings