Skip to content

Commit d91f267

Browse files
authored
Merge pull request #155 from brunomikoski/bugfix/fix-items-not-being-applied
fix: items not being saved without ApplyModifiedProperties()
2 parents 4aeaf16 + 7b58201 commit d91f267

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

CHANGELOG.MD

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
## [2.3.5]
9+
## Changed
10+
- Added `ApplyModifiedProperties()` to property drawers again, since was causing issues with the shareable picker. This was removed on [2.3.4]
11+
12+
813
## [2.3.4]
914
## Changed
1015
- Update PickerPropertyDrawer to use PopupList from property path cache to avoid issue when rendered inside a List/Array
@@ -582,6 +587,7 @@ public bool IsValidConsumable(Consumable consumable)
582587
### Added
583588
- First initial working version
584589

590+
[2.3.5]: https://github.com/badawe/ScriptableObjectCollection/releases/tag/v2.3.5~~~~
585591
[2.3.4]: https://github.com/badawe/ScriptableObjectCollection/releases/tag/v2.3.4
586592
[2.3.3]: https://github.com/badawe/ScriptableObjectCollection/releases/tag/v2.3.3
587593
[2.3.2]: https://github.com/badawe/ScriptableObjectCollection/releases/tag/v2.3.2

Scripts/Editor/PropertyDrawers/CollectionItemIndirectReferencePropertyDrawer.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,17 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
6464

6565
if (collectionItemPropertyDrawer.OptionsAttribute.DrawType == DrawType.Dropdown)
6666
{
67-
DrawItemDrawer(position, property, label, collectionItem);
67+
collectionItemPropertyDrawer.DrawCollectionItemDrawer(ref position, property, collectionItem, label, item =>
68+
{
69+
SetSerializedPropertyGUIDs(item);
70+
drawingProperty.serializedObject.ApplyModifiedProperties();
71+
});
6872
return;
6973
}
7074

7175
EditorGUI.PropertyField(position, property, label, true);
7276
}
7377

74-
private void DrawItemDrawer(Rect position, SerializedProperty property, GUIContent label, ScriptableObject collectionItem)
75-
{
76-
collectionItemPropertyDrawer.DrawCollectionItemDrawer(ref position, property, collectionItem, label, SetSerializedPropertyGUIDs);
77-
}
78-
7978
private void SetSerializedPropertyGUIDs(ScriptableObject item)
8079
{
8180
if (item == null)
@@ -103,6 +102,7 @@ private void SetSerializedPropertyGUIDs(ScriptableObject item)
103102
collectionLastKnowNameSerializedProperty.stringValue = socItem.Collection.name;
104103
}
105104
}
105+
106106
}
107107

108108
private bool TryGetCollectionItem(out ScriptableObject item)

Scripts/Editor/PropertyDrawers/CollectionItemPickerPropertyDrawer.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ private void GetValuesFromPopup(PopupList<PopupItem> popupList, SerializedProper
187187
propertyArrayIndex++;
188188
}
189189
}
190+
191+
itemsProperty.serializedObject.ApplyModifiedProperties();
190192
}
191193

192194
private void AssignItemGUIDToProperty(ScriptableObject scriptableObject, SerializedProperty newProperty)
@@ -246,6 +248,8 @@ private void SetSelectedValuesOnPopup(PopupList<PopupItem> popupList, Serialized
246248
itemsProperty.DeleteArrayElementAtIndex(i);
247249
}
248250
}
251+
252+
itemsProperty.serializedObject.ApplyModifiedProperties();
249253
}
250254

251255
private LongGuid GetGUIDFromProperty(SerializedProperty property)

Scripts/Editor/PropertyDrawers/CollectionItemPropertyDrawer.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
102102
newItem =>
103103
{
104104
property.objectReferenceValue = newItem;
105+
property.serializedObject.ApplyModifiedProperties();
105106
});
106107
}
107108
EditorGUI.EndProperty();

0 commit comments

Comments
 (0)