public void HandleDrawnType(SerializedProperty property, Type drawnType, Type propertyType, FieldInfo field, PropertyAttribute attribute) { Type drawerType = ScriptAttributeUtility.GetDrawerTypeForPropertyAndType(property, drawnType); // If we found a drawer type, instantiate the drawer, cache it, and return it. if (drawerType != null) { if (typeof(PropertyDrawer).IsAssignableFrom(drawerType)) { // Use PropertyDrawer on array elements, not on array itself. // If there's a PropertyAttribute on an array, we want to apply it to the individual array elements instead. // This is the only convenient way we can let the user apply PropertyDrawer attributes to elements inside an array. if (propertyType != null && propertyType.IsArrayOrList()) { return; } var propertyDrawerForType = (PropertyDrawer)System.Activator.CreateInstance(drawerType); propertyDrawerForType.m_FieldInfo = field; // Will be null by design if default type drawer! propertyDrawerForType.m_Attribute = attribute; if (m_PropertyDrawers == null) { m_PropertyDrawers = new List <PropertyDrawer>(); } m_PropertyDrawers.Add(propertyDrawerForType); } else if (typeof(DecoratorDrawer).IsAssignableFrom(drawerType)) { // Draw decorators on array itself, not on each array elements if (field != null && field.FieldType.IsArrayOrList() && !propertyType.IsArrayOrList()) { return; } DecoratorDrawer decoratorDrawerForType = (DecoratorDrawer)System.Activator.CreateInstance(drawerType); decoratorDrawerForType.m_Attribute = attribute; if (m_DecoratorDrawers == null) { m_DecoratorDrawers = new List <DecoratorDrawer>(); } m_DecoratorDrawers.Add(decoratorDrawerForType); } } }