Пример #1
0
 static ReorderableListAttributeDrawer()
 {
     storage = new DrawerDataStorage <ReorderableList, ReorderableListAttribute>(false, (p, a) =>
     {
         return(ToolboxEditorGui.CreateList(p,
                                            a.ListStyle,
                                            a.ElementLabel,
                                            a.FixedSize,
                                            a.Draggable,
                                            a.HasHeader));
     });
 }
        /// <summary>
        /// Draws <see cref="ReorderableList"/> if provided property is previously cached array/list or creates completely new instance.
        /// </summary>
        /// <param name="property">Property to draw.</param>
        /// <param name="attribute"></param>
        protected override void OnGuiSafe(SerializedProperty property, GUIContent label, ReorderableListAttribute attribute)
        {
            var key = property.GetPropertyKey();

            if (!listInstances.TryGetValue(key, out ReorderableList list))
            {
                listInstances[key] = list = ToolboxEditorGui.CreateList(property,
                                                                        attribute.ListStyle,
                                                                        attribute.ElementLabel,
                                                                        attribute.FixedSize,
                                                                        attribute.Draggable);
            }

            list.DoLayoutList();
        }
        /// <summary>
        /// Draws <see cref="ReorderableList"/> if provided property is previously cached array/list or creates completely new instance.
        /// </summary>
        /// <param name="property">Property to draw.</param>
        /// <param name="attribute"></param>
        public override void OnGui(SerializedProperty property, ReorderableListAttribute attribute)
        {
            var key = GenerateKey(property);

            if (!listInstances.TryGetValue(key, out ReorderableList list))
            {
                listInstances[key] = list = ToolboxEditorGui.CreateList(property,
                                                                        attribute.ListStyle,
                                                                        attribute.ElementLabel,
                                                                        attribute.FixedSize,
                                                                        attribute.Draggable);
            }

            list.DoLayoutList();
        }
 static ReorderableListExposedAttributeDrawer()
 {
     storage = new DrawerDataStorage <ReorderableListBase, ReorderableListExposedAttribute>(false, (p, a) =>
     {
         //create list in the standard way
         var list = ToolboxEditorGui.CreateList(p,
                                                a.ListStyle,
                                                a.ElementLabel,
                                                a.FixedSize,
                                                a.Draggable,
                                                a.HasHeader,
                                                a.HasLabels);
         //additionaly subscribe callbacks
         ConnectCallbacks(list, a);
         return(list);
     });
 }