Ejemplo n.º 1
0
 public static void SettingList(Setting setting, ElementCallbackDelegate OnDrawElement = null,
                                float elementHeight = 0)
 {
     // setup the list
     PaneGUI.setting     = setting;
     rlist               = rlist ?? new ReorderableList(null, typeof(IList));
     rlist.list          = (IList)setting.field.GetValue(setting.obj);
     rlist.headerHeight  = 2;
     rlist.elementHeight = elementHeight > 0 ? elementHeight :
                           EditorGUIUtility.singleLineHeight + 4;
     rlist.footerHeight            = EditorGUIUtility.singleLineHeight + 3;
     rlist.drawElementCallback     = OnDrawElement ?? PaneGUI.OnDrawElement;
     rlist.onAddCallback           = OnAddElement;
     rlist.onRemoveCallback        = OnRemoveElement;
     rlist.onReorderCallback       = OnReorder;
     rlist.drawNoneElementCallback = OnEmptyList;
     rlist.showDefaultBackground   = true;
     // draw the reorderable list
     EditorGUILayout.BeginHorizontal();
     EditorGUILayout.PrefixLabel(setting.label);
     GUILayout.BeginVertical(Styles.listStyle);
     GUILayout.Space(1);
     rlist.DoLayoutList();
     GUILayout.EndVertical();
     EditorGUILayout.EndHorizontal();
 }
Ejemplo n.º 2
0
        public PrettyListViewer(
            SerializedObject serializedObject,
            SerializedProperty elements,
            HeaderCallbackDelegate onDrawHeader,
            ElementCallbackDelegate onDrawElement,
            ElementHeightCallbackDelegate elementHeightGetter,
            ReorderCallbackDelegate onReorder = null,
            AddCallbackDelegate onAdd         = null,
            RemoveCallbackDelegate onRemove   = null
            ) : base(serializedObject, elements)
        {
            drawHeaderCallback    = onDrawHeader;
            drawElementCallback   = onDrawElement;
            elementHeightCallback = elementHeightGetter;

            if (onReorder != null)
            {
                draggable         = true;
                onReorderCallback = onReorder;
            }
            else
            {
                draggable = false;
            }

            if (onAdd != null)
            {
                displayAdd    = true;
                onAddCallback = onAdd;
            }
            else
            {
                displayAdd = false;
            }

            if (onRemove != null)
            {
                displayRemove    = true;
                onRemoveCallback = onRemove;
            }
            else
            {
                displayRemove = false;
            }
        }
Ejemplo n.º 3
0
 public GenericReorderableList(SerializedObject serializedObject, SerializedProperty elements, bool draggable, bool displayHeader, bool displayAddButton, bool displayRemoveButton) : base(serializedObject, elements, draggable, displayHeader, displayAddButton, displayRemoveButton)
 {
     drawElementCallback   = new ElementCallbackDelegate(DrawElement);
     drawHeaderCallback    = new HeaderCallbackDelegate(DrawHeader);
     elementHeightCallback = new ElementHeightCallbackDelegate(ElementHeight);
 }
Ejemplo n.º 4
0
 public GenericReorderableList(IList elements, Type elementType, bool draggable, bool displayHeader, bool displayAddButton, bool displayRemoveButton) : base(elements, elementType, draggable, displayHeader, displayAddButton, displayRemoveButton)
 {
     drawElementCallback   = new ElementCallbackDelegate(DrawElement);
     drawHeaderCallback    = new HeaderCallbackDelegate(DrawHeader);
     elementHeightCallback = new ElementHeightCallbackDelegate(ElementHeight);
 }
Ejemplo n.º 5
0
 public GenericReorderableList(SerializedObject serializedObject, SerializedProperty elements) : base(serializedObject, elements)
 {
     drawElementCallback   = new ElementCallbackDelegate(DrawElement);
     drawHeaderCallback    = new HeaderCallbackDelegate(DrawHeader);
     elementHeightCallback = new ElementHeightCallbackDelegate(ElementHeight);
 }
Ejemplo n.º 6
0
 public GenericReorderableList(IList elements, Type elementType) : base(elements, elementType)
 {
     drawElementCallback   = new ElementCallbackDelegate(DrawElement);
     drawHeaderCallback    = new HeaderCallbackDelegate(DrawHeader);
     elementHeightCallback = new ElementHeightCallbackDelegate(ElementHeight);
 }
Ejemplo n.º 7
0
 public NoHeaderReorderableList(SerializedObject serializedObject, SerializedProperty elements, ElementCallbackDelegate drawCallback, int rowByElement) : base(serializedObject, elements, true, false, true, true)
 {
     headerHeight        = 2f;
     drawElementCallback = drawCallback;
     AdjustElementHeight(rowByElement);
 }
Ejemplo n.º 8
0
 public FoldableReordableList(SerializedObject sObject, SerializedProperty sProperty, bool draggable, bool displayHeader, bool displayAddButton, bool displayRemovebutton, string listTitle, float elementHeightFactor, ElementCallbackDelegate elementCallbackDelegate)
     : base(sObject, sProperty, draggable, displayHeader, displayAddButton, displayRemovebutton)
 {
     this.drawHeaderCallback = (Rect rect) =>
     {
         rect.x   += 15;
         displayed = EditorGUI.Foldout(rect, displayed, listTitle, true);
     };
     this.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) =>
     {
         if (displayed)
         {
             rect.y      += 2;
             rect.height -= 5;
             elementCallbackDelegate(rect, index, isActive, isFocused);
         }
     };
     elementHeightCallback = (int index) =>
     {
         if (displayed)
         {
             return(elementHeight * elementHeightFactor);
         }
         else
         {
             return(0);
         }
     };
 }
Ejemplo n.º 9
0
 public FoldableReordableList(List <T> list, bool draggable, bool displayHeader, bool displayAddButton, bool displayRemovebutton, string listTitle, float elementHeightFactor, ElementCallbackDelegate elementCallbackDelegate, ElementHeightCallbackDelegate elementHeightCallBack = null)
     : base(list, typeof(T), draggable, displayHeader, displayAddButton, displayRemovebutton)
 {
     this.drawHeaderCallback = (Rect rect) =>
     {
         rect.x   += 15;
         displayed = EditorGUI.Foldout(rect, displayed, listTitle, true, EditorStyles.foldout);
         if (displayed)
         {
             this.draggable     = true;
             this.displayAdd    = true;
             this.displayRemove = true;
         }
         else
         {
             this.draggable     = false;
             this.displayAdd    = false;
             this.displayRemove = false;
         }
     };
     this.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) =>
     {
         if (displayed)
         {
             rect.y      += 2;
             rect.height -= 5;
             elementCallbackDelegate(rect, index, isActive, isFocused);
         }
     };
     this.elementHeightCallback = elementHeightCallBack;
     if (elementHeightCallback == null)
     {
         this.elementHeightCallback = (int index) =>
         {
             if (displayed)
             {
                 return(elementHeight * elementHeightFactor);
             }
             else
             {
                 return(0);
             }
         };
     }
 }