Skip to content

Commit 5ee484f

Browse files
committed
Clear InLinedEditor after folding properties; improve displaying mixed values while using the ReferencePickerAttribute; improve footer position in the ReorderableList class
1 parent 7ac87ff commit 5ee484f

File tree

6 files changed

+70
-20
lines changed

6 files changed

+70
-20
lines changed

Assets/Editor Toolbox/Editor/Drawers/Toolbox/PropertySelf/InLineEditorAttributeDrawer.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ static InLineEditorAttributeDrawer()
4646

4747
private static readonly PropertyDataStorage<Editor, InLineEditorAttribute> storage;
4848

49-
5049
private Editor GetTargetsEditor(SerializedProperty property, InLineEditorAttribute attribute)
5150
{
5251
var editor = storage.ReturnItem(property, attribute);
@@ -108,7 +107,6 @@ private void DrawEditor(Editor editor, bool disableEditor, bool drawPreview, boo
108107
}
109108
}
110109

111-
112110
/// <summary>
113111
/// Handles the property drawing process and tries to create a inlined version of the <see cref="Editor"/>.
114112
/// </summary>
@@ -151,15 +149,17 @@ protected override void OnGuiSafe(SerializedProperty property, GUIContent label,
151149
DrawEditor(editor, attribute);
152150
}
153151
}
152+
else
153+
{
154+
storage.ClearItem(property);
155+
}
154156
}
155157

156-
157158
public override bool IsPropertyValid(SerializedProperty property)
158159
{
159160
return property.propertyType == SerializedPropertyType.ObjectReference;
160161
}
161162

162-
163163
private static class Style
164164
{
165165
internal static readonly GUIStyle backgroundStyle;

Assets/Editor Toolbox/Editor/Drawers/Toolbox/PropertySelf/ReferencePickerAttributeDrawer.cs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,38 @@ private Type GetParentType(ReferencePickerAttribute attribute, SerializedPropert
4141
return fieldType;
4242
}
4343

44+
private static Type GetCurrentManagedReferenceType(SerializedProperty property, out bool hasMixedValues)
45+
{
46+
var fullTypeName = property.managedReferenceFullTypename;
47+
hasMixedValues = false;
48+
TypeUtility.TryGetTypeFromManagedReferenceFullTypeName(fullTypeName, out var targetType);
49+
50+
var currentSerializedObject = property.serializedObject;
51+
if (currentSerializedObject.isEditingMultipleObjects)
52+
{
53+
var targets = currentSerializedObject.targetObjects;
54+
foreach (var target in targets)
55+
{
56+
using (var tempSerializedObject = new SerializedObject(target))
57+
{
58+
var tempProperty = tempSerializedObject.FindProperty(property.propertyPath);
59+
if (tempProperty.managedReferenceFullTypename != fullTypeName)
60+
{
61+
hasMixedValues = true;
62+
break;
63+
}
64+
}
65+
}
66+
}
67+
68+
return targetType;
69+
}
70+
4471
private void CreateTypeProperty(SerializedProperty property, Type parentType, ReferencePickerAttribute attribute, Rect position)
4572
{
46-
TypeUtility.TryGetTypeFromManagedReferenceFullTypeName(property.managedReferenceFullTypename, out var currentType);
73+
var currentType = GetCurrentManagedReferenceType(property, out var hasMixedValues);
74+
var hadMixedValues = EditorGUI.showMixedValue;
75+
EditorGUI.showMixedValue = hasMixedValues;
4776
typeField.OnGui(position, attribute.AddTextSearchField, (type) =>
4877
{
4978
try
@@ -70,6 +99,7 @@ private void CreateTypeProperty(SerializedProperty property, Type parentType, Re
7099
ToolboxEditorLog.LogWarning("Invalid attempt to update disposed property.");
71100
}
72101
}, currentType, parentType);
102+
EditorGUI.showMixedValue = false;
73103
}
74104

75105
private void UpdateTypeProperty(SerializedProperty property, Type targetType, ReferencePickerAttribute attribute)

Assets/Editor Toolbox/Editor/Internal/ReorderableListBase.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,8 @@ protected virtual bool DoListFooter(Rect footerRect)
334334
return false;
335335
}
336336

337+
footerRect.yMax += Style.footerXOffset;
338+
footerRect.yMin += Style.footerYOffset;
337339
//draw the background on repaint event
338340
if (Event.current.type == EventType.Repaint)
339341
{
@@ -870,6 +872,8 @@ protected static class Style
870872
#else
871873
internal static readonly float lineHeight = 16.0f;
872874
#endif
875+
internal static readonly float footerXOffset = 0.0f;
876+
internal static readonly float footerYOffset = -1.0f;
873877
internal static readonly float footerWidth = 60.0f;
874878
internal static readonly float footerButtonWidth = 25.0f;
875879
internal static readonly float footerButtonHeight = 13.0f;

Packages/manifest.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"com.unity.editorcoroutines": "1.0.0",
88
"com.unity.ide.rider": "3.0.18",
99
"com.unity.ide.visualstudio": "2.0.17",
10-
"com.unity.ide.vscode": "1.2.5",
1110
"com.unity.test-framework": "1.1.31",
1211
"com.unity.textmeshpro": "3.0.6",
1312
"com.unity.timeline": "1.6.4",

Packages/packages-lock.json

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@
1010
"version": "1.0.0",
1111
"depth": 0,
1212
"source": "builtin",
13-
"dependencies": {
14-
"com.unity.modules.tilemap": "1.0.0",
15-
"com.unity.modules.uielements": "1.0.0"
16-
}
13+
"dependencies": {}
1714
},
1815
"com.unity.analytics": {
1916
"version": "3.6.12",
@@ -63,26 +60,19 @@
6360
},
6461
"url": "https://packages.unity.com"
6562
},
66-
"com.unity.ide.vscode": {
67-
"version": "1.2.5",
68-
"depth": 0,
69-
"source": "registry",
70-
"dependencies": {},
71-
"url": "https://packages.unity.com"
72-
},
7363
"com.unity.sysroot": {
74-
"version": "2.0.5",
64+
"version": "1.0.0",
7565
"depth": 1,
7666
"source": "registry",
7767
"dependencies": {},
7868
"url": "https://packages.unity.com"
7969
},
8070
"com.unity.sysroot.linux-x86_64": {
81-
"version": "2.0.4",
71+
"version": "1.0.0",
8272
"depth": 1,
8373
"source": "registry",
8474
"dependencies": {
85-
"com.unity.sysroot": "2.0.5"
75+
"com.unity.sysroot": "1.0.0"
8676
},
8777
"url": "https://packages.unity.com"
8878
},
@@ -279,6 +269,17 @@
279269
"version": "1.0.0",
280270
"depth": 0,
281271
"source": "builtin",
272+
"dependencies": {
273+
"com.unity.modules.ui": "1.0.0",
274+
"com.unity.modules.imgui": "1.0.0",
275+
"com.unity.modules.jsonserialize": "1.0.0",
276+
"com.unity.modules.uielementsnative": "1.0.0"
277+
}
278+
},
279+
"com.unity.modules.uielementsnative": {
280+
"version": "1.0.0",
281+
"depth": 1,
282+
"source": "builtin",
282283
"dependencies": {
283284
"com.unity.modules.ui": "1.0.0",
284285
"com.unity.modules.imgui": "1.0.0",
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!114 &1
4+
MonoBehaviour:
5+
m_ObjectHideFlags: 61
6+
m_CorrespondingSourceObject: {fileID: 0}
7+
m_PrefabInstance: {fileID: 0}
8+
m_PrefabAsset: {fileID: 0}
9+
m_GameObject: {fileID: 0}
10+
m_Enabled: 1
11+
m_EditorHideFlags: 0
12+
m_Script: {fileID: 11500000, guid: a287be6c49135cd4f9b2b8666c39d999, type: 3}
13+
m_Name:
14+
m_EditorClassIdentifier:
15+
assetDefaultFramerate: 60
16+
m_DefaultFrameRate: 60

0 commit comments

Comments
 (0)