static InLineEditorAttributeDrawer()
        {
            storage = new DrawerDataStorage <Editor, InLineEditorAttribute>(false,
                                                                            (p, a) =>
            {
                var value = p.objectReferenceValue;
                if (value)
                {
                    var editor = Editor.CreateEditor(value);
                    if (editor.HasPreviewGUI())
                    {
                        editor.ReloadPreviewInstances();
                    }

                    return(editor);
                }
                else
                {
                    return(null);
                }
            },
                                                                            (e) =>
            {
                Object.DestroyImmediate(e);
            });
        }
        static SerializedDictionaryDrawer()
        {
            storage = new DrawerDataStorage <ReorderableListBase, CreationArgs>(false, (p, a) =>
            {
                var pairsProperty = a.pairsProperty;
                var errorProperty = a.errorProperty;

                var list = new ToolboxEditorList(pairsProperty, "Pair", true, true, false);
                list.drawHeaderCallback += (rect) =>
                {
                    //cache preprocessed label to get prefab related functions
                    var label = EditorGUI.BeginProperty(rect, null, p);
                    //create additional warning message if there is key collision
                    if (errorProperty.boolValue)
                    {
                        label.image = EditorGuiUtility.GetHelpIcon(MessageType.Warning);
                        label.text += string.Format(" [{0}]", Style.warningMessage);
                    }
                    EditorGUI.LabelField(rect, label);
                    EditorGUI.EndProperty();
                };
                list.drawFooterCallback += (rect) =>
                {
                    list.DrawStandardFooter(rect);
                };
                list.drawElementCallback += (rect, index, isActive, isFocused) =>
                {
                    list.DrawStandardElement(rect, index, isActive, isFocused, true);
                };
                return(list);
            });
        }
示例#3
0
 static ScrollableItemsAttributeDrawer()
 {
     storage = new DrawerDataStorage <Vector2, ScrollableItemsAttribute>(true, (p, a) =>
     {
         return(new Vector2(a.DefaultMinIndex, a.DefaultMaxIndex));
     });
 }
示例#4
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));
     });
 }
示例#5
0
        static SerializedDictionaryDrawer()
        {
            storage = new DrawerDataStorage <ReorderableListBase, CreationArgs>(false, (p, a) =>
            {
                var pairsProperty = a.pairsProperty;
                var errorProperty = a.errorProperty;

                var list = new ToolboxEditorList(pairsProperty, "Pair", true, true, false);
                list.drawHeaderCallback += (rect) =>
                {
                    //cache preprocessed label to get prefab related functions
                    var label = EditorGUI.BeginProperty(rect, null, p);
                    //create additional warning message if there is key collision
                    if (errorProperty.boolValue)
                    {
                        label.image = EditorGuiUtility.GetHelpIcon(MessageType.Warning);
                        label.text += string.Format(" [{0}]", Style.warningMessage);
                    }
                    EditorGUI.LabelField(rect, label);
                    EditorGUI.EndProperty();
                };
                list.drawFooterCallback += (rect) =>
                {
                    list.DrawStandardFooter(rect);
                };
                list.drawElementCallback += (rect, index, isActive, isFocused) =>
                {
                    var element = pairsProperty.GetArrayElementAtIndex(index);
                    var content = list.GetElementContent(element, index);

                    using (var propertyScope = new PropertyScope(element, content))
                    {
                        if (!propertyScope.IsVisible)
                        {
                            return;
                        }

                        //draw key/value children and use new, shortened labels
                        EditorGUI.indentLevel++;
                        EditorGUILayout.PropertyField(element.FindPropertyRelative("key"), new GUIContent("K"));
                        EditorGUILayout.PropertyField(element.FindPropertyRelative("value"), new GUIContent("V"));
                        EditorGUI.indentLevel--;
                    }
                };
                return(list);
            });
        }
 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);
     });
 }