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); }); }
public void SetUp() { var target = ScriptableObject.CreateInstance <TestObject2>(); scriptableObject = new SerializedObject(target); var array = scriptableObject.FindProperty("var2.var3"); list = new ToolboxEditorList(array); }
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); }); }