public ReorderableListOfStructures( ReorderableListAttribute attribute, SerializedProperty property, Type listType, Type elementType) : base(attribute, property, listType, elementType) { }
//---------------------------------------------------------------------- public ReorderableListOfValues( ReorderableListAttribute attribute, SerializedProperty primaryProperty, Type listType, Type elementType) : base( serializedObject: primaryProperty.serializedObject, elements: primaryProperty.Copy(), draggable: !attribute.disableDragging, displayHeader: true, displayAddButton: !attribute.disableAdding, displayRemoveButton: !attribute.disableRemoving) { this.listType = listType; this.elementType = elementType; this.elementHeaderFormat = attribute.elementHeaderFormat; this.showFooterButtons = (displayAdd || displayRemove) && !attribute.hideFooterButtons; this.singularListHeaderFormat = attribute.singularListHeaderFormat ?? "{0} ({1})"; this.pluralListHeaderFormat = attribute.pluralListHeaderFormat ?? "{0} ({1})"; this.backgroundColor = new Color( attribute.r, attribute.g, attribute.b); this.serializedProperties = AcquireSerializedProperties( this.serializedProperty, attribute.parallelListNames); this.parallelListLayout = attribute.parallelListLayout; headerHeight -= 2; drawHeaderCallback = DrawHeaderCallback; drawFooterCallback = DrawFooterCallback; elementHeightCallback = ElementHeightCallback; drawElementCallback = DrawElementCallback; drawElementBackgroundCallback = DrawElementBackgroundCallback; onAddCallback = OnAddCallback; onCanRemoveCallback = OnCanRemoveCallback; onRemoveCallback = OnRemoveCallback; onSelectCallback = OnSelectCallback; onReorderCallback = OnReorderCallback; #if UNITY_2018_1_OR_NEWER drawNoneElementCallback = DrawEmptyElementCallback; #endif // UNITY_2018_1_OR_NEWER }
GetReorderableList( ReorderableListAttribute attribute, FieldInfo fieldInfo, SerializedProperty property) { var propertyPath = property.propertyPath; if (m_MostRecentReorderableList != null) { if (m_MostRecentPropertyPath == propertyPath) { m_MostRecentReorderableList.serializedProperty = property; return(m_MostRecentReorderableList); } } m_MostRecentReorderableList = m_ReorderableListMap .Find(propertyPath); if (m_MostRecentReorderableList == null) { var reorderableList = CreateReorderableList( attribute, fieldInfo, property); m_ReorderableListMap.Add(propertyPath, reorderableList); m_MostRecentReorderableList = reorderableList; } else { m_MostRecentReorderableList.serializedProperty = property; } m_MostRecentPropertyPath = propertyPath; return(m_MostRecentReorderableList); }
//---------------------------------------------------------------------- public ReorderableListOfSubassets( ReorderableListAttribute attribute, SerializedProperty property, Type listType, Type elementType, Type[] subassetTypes) : base(attribute, property, listType, elementType) { m_SubassetTypes = subassetTypes; m_UseFullSubassetTypeNames = SubassetTypeNamesAreAmbiguous(); onCanAddCallback = OnCanAddCallback; if (hasSingleSubassetType) { onAddCallback = OnAddCallback; } else if (hasMultipleSubassetTypes) { onAddDropdownCallback = OnAddDropdownCallback; } }
CreateReorderableList( ReorderableListAttribute attribute, FieldInfo fieldInfo, SerializedProperty property) { var listType = fieldInfo.FieldType; var elementType = GetArrayOrListElementType(listType); var elementIsValue = elementType.IsEnum || elementType.IsPrimitive || elementType == typeof(string) || elementType == typeof(Color) || elementType == typeof(LayerMask) || elementType == typeof(Vector2) || elementType == typeof(Vector3) || elementType == typeof(Vector4) || elementType == typeof(Rect) || elementType == typeof(AnimationCurve) || elementType == typeof(Bounds) || elementType == typeof(Gradient) || elementType == typeof(Quaternion) || elementType == typeof(Vector2Int) || elementType == typeof(Vector3Int) || elementType == typeof(RectInt) || elementType == typeof(BoundsInt); if (elementIsValue) { return (new ReorderableListOfValues( attribute, property, listType, elementType )); } var elementIsUnityEngineObject = typeof(UnityEngine.Object) .IsAssignableFrom(elementType); if (elementIsUnityEngineObject) { var elementsAreSubassets = elementIsUnityEngineObject && attribute != null && attribute.elementsAreSubassets; if (elementsAreSubassets) { var assemblies = AppDomain.CurrentDomain.GetAssemblies(); var types = assemblies.SelectMany(a => a.GetTypes()); var subassetTypes = types.Where(t => t.IsAbstract == false && t.IsGenericTypeDefinition == false && elementType.IsAssignableFrom(t) ) .ToArray(); return (new ReorderableListOfSubassets( attribute, property, listType, elementType, subassetTypes )); } else { return (new ReorderableListOfValues( attribute, property, listType, elementType )); } } var elementPropertyDrawerType = GetDrawerTypeForType(elementType); if (elementPropertyDrawerType == null) { var elementIsStruct = elementType.IsValueType && elementType.IsEnum == false && elementType.IsPrimitive == false; var elementIsClass = elementType.IsClass; if (elementIsStruct || elementIsClass) { return (new ReorderableListOfStructures( attribute, property, listType, elementType )); } } return (new ReorderableListOfValues( attribute, property, listType, elementType )); }