示例#1
0
        public static ReorderableList GetList(SerializedProperty property, ReorderableAttribute attrib, int id, string arrayPropertyName)
        {
            if (property == null)
            {
                return(null);
            }

            ReorderableList    list  = null;
            SerializedProperty array = property.FindPropertyRelative(arrayPropertyName);

            if (array != null && array.isArray)
            {
                if (!lists.TryGetValue(id, out list))
                {
                    if (attrib != null)
                    {
                        Texture icon = !string.IsNullOrEmpty(attrib.elementIconPath) ? AssetDatabase.GetCachedIcon(attrib.elementIconPath) : null;

                        ReorderableList.ElementDisplayType displayType = attrib.singleLine ? ReorderableList.ElementDisplayType.SingleLine : ReorderableList.ElementDisplayType.Auto;

                        list               = new ReorderableList(array, attrib.add, attrib.remove, attrib.draggable, displayType, attrib.elementNameProperty, attrib.elementNameOverride, icon);
                        list.paginate      = attrib.paginate;
                        list.pageSize      = attrib.pageSize;
                        list.sortable      = attrib.sortable;
                        list.elementLabels = attrib.labels;

                        //handle surrogate if any

                        if (attrib.surrogateType != null)
                        {
                            SurrogateCallback callback = new SurrogateCallback(attrib.surrogateProperty);

                            list.surrogate = new ReorderableList.Surrogate(attrib.surrogateType, callback.SetReference);
                        }
                    }
                    else
                    {
                        list = new ReorderableList(array, true, true, true);
                    }

                    lists.Add(id, list);
                }
                else
                {
                    list.List = array;
                }
            }

            return(list);
        }
示例#2
0
 public static ReorderableList GetList(SerializedProperty property, ReorderableAttribute attrib, string arrayPropertyName)
 {
     return(GetList(property, attrib, GetListId(property), arrayPropertyName));
 }