Skip to content

fix: items not being saved without ApplyModifiedProperties() #155

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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