I’m trying to make a custom editor that allow you to multi-edit serializedProperty of multiples element from a single array.
I’m therefore trying to use EditorGUI.showMixedValue to modify the appearance of property field whose values differ from one edited element to the other, but it seems to be doing nothing.
Trying to put this code in a working Editor class:
Give me this result:
The line “EditorGUI.showMixedValue = true” didn’t change anything about the appearance of the property field.
I thought it would give me this:
Is EditorGUI.showMixedValue not working as intended or am I not understanding what it should do ?
I could use another appearance to make explicit the fact that a field represent properties with different values but I would have liked to keep unity default appearance. Can I mimic it another way ?
Well, you use PropertyField to draw your property. The default property drawer will actually look at the SerializedProperty.hasMultipleDifferentValues and probably set this to true / false internally. The point of the SerializedObject / SerializedProperty is to abstract multiple objects behind a single one.
The method PropertyField is a very high level method which does handle everything for you. It calls custom property drawers and if “includeChildren” is set to true it may even draw child properties.
If you want to customize how a property is actually shown you may want to look at more low level drawing methods. However I don’t quite see the point in drawing a property as “having multiple different values” when it actually has not. Do you actually edit multiple objects at once?
I didn’t think about that, thanks for the answer !
I do not edit multiples unity objects at once but I do edit multiples classes at once.
Basically I have some buttons at the top allowing you to select multiple elements from an array, for example element 0, 1 and 2, and then a single property field that will reference values from all selected elements.