static InLineEditorAttributeDrawer()
        {
            storage = new PropertyDataStorage <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 ScrollableItemsAttributeDrawer()
 {
     storage = new PropertyDataStorage <Vector2, ScrollableItemsAttribute>(true, (p, a) =>
     {
         return(new Vector2(a.DefaultMinIndex, a.DefaultMaxIndex));
     });
 }
Esempio n. 3
0
 static ReorderableListAttributeDrawer()
 {
     storage = new PropertyDataStorage <ReorderableListBase, ReorderableListAttribute>(false, (p, a) =>
     {
         return(ToolboxEditorGui.CreateList(p,
                                            a.ListStyle,
                                            a.ElementLabel,
                                            a.FixedSize,
                                            a.Draggable,
                                            a.HasHeader,
                                            a.HasLabels,
                                            a.Foldable));
     });
 }
Esempio n. 4
0
        static SerializedDictionaryDrawer()
        {
            storage = new PropertyDataStorage <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 a 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 PropertyDataStorage <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,
                                                a.Foldable);
         //additionaly subscribe callbacks
         ConnectCallbacks(list, a);
         return(list);
     });
 }