Skip to content

Commit

Permalink
fix: items not being saved without ApplyModifiedProperties()
Browse files Browse the repository at this point in the history
  • Loading branch information
brunomikoski committed Aug 30, 2024
1 parent 4aeaf16 commit 7b58201
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [2.3.5]
## Changed
- Added `ApplyModifiedProperties()` to property drawers again, since was causing issues with the shareable picker. This was removed on [2.3.4]


## [2.3.4]
## Changed
- Update PickerPropertyDrawer to use PopupList from property path cache to avoid issue when rendered inside a List/Array
Expand Down Expand Up @@ -582,6 +587,7 @@ public bool IsValidConsumable(Consumable consumable)
### Added
- First initial working version

[2.3.5]: https://github.com/badawe/ScriptableObjectCollection/releases/tag/v2.3.5~~~~
[2.3.4]: https://github.com/badawe/ScriptableObjectCollection/releases/tag/v2.3.4
[2.3.3]: https://github.com/badawe/ScriptableObjectCollection/releases/tag/v2.3.3
[2.3.2]: https://github.com/badawe/ScriptableObjectCollection/releases/tag/v2.3.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,17 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten

if (collectionItemPropertyDrawer.OptionsAttribute.DrawType == DrawType.Dropdown)
{
DrawItemDrawer(position, property, label, collectionItem);
collectionItemPropertyDrawer.DrawCollectionItemDrawer(ref position, property, collectionItem, label, item =>
{
SetSerializedPropertyGUIDs(item);
drawingProperty.serializedObject.ApplyModifiedProperties();
});
return;
}

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

private void DrawItemDrawer(Rect position, SerializedProperty property, GUIContent label, ScriptableObject collectionItem)
{
collectionItemPropertyDrawer.DrawCollectionItemDrawer(ref position, property, collectionItem, label, SetSerializedPropertyGUIDs);
}

private void SetSerializedPropertyGUIDs(ScriptableObject item)
{
if (item == null)
Expand Down Expand Up @@ -103,6 +102,7 @@ private void SetSerializedPropertyGUIDs(ScriptableObject item)
collectionLastKnowNameSerializedProperty.stringValue = socItem.Collection.name;
}
}

}

private bool TryGetCollectionItem(out ScriptableObject item)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ private void GetValuesFromPopup(PopupList<PopupItem> popupList, SerializedProper
propertyArrayIndex++;
}
}

itemsProperty.serializedObject.ApplyModifiedProperties();
}

private void AssignItemGUIDToProperty(ScriptableObject scriptableObject, SerializedProperty newProperty)
Expand Down Expand Up @@ -246,6 +248,8 @@ private void SetSelectedValuesOnPopup(PopupList<PopupItem> popupList, Serialized
itemsProperty.DeleteArrayElementAtIndex(i);
}
}

itemsProperty.serializedObject.ApplyModifiedProperties();
}

private LongGuid GetGUIDFromProperty(SerializedProperty property)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
newItem =>
{
property.objectReferenceValue = newItem;
property.serializedObject.ApplyModifiedProperties();
});
}
EditorGUI.EndProperty();
Expand Down

0 comments on commit 7b58201

Please sign in to comment.