Fixed collection deserialization problem. (#300)

* Fixed collection deserialization problem

ScriptableObjects arent granted to be initialized on a particular order and might be used by the collection before they are initialized.

* Update CHANGELOG.md

Co-authored-by: eduardo <eduardo@firasoft.com>
Co-authored-by: Casey Hofland <hofland.casey@gmail.com>
This commit is contained in:
Kyrw 2021-09-23 16:39:23 -03:00 committed by GitHub
parent 7b29e15be2
commit a7c9c69fcf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View File

@ -8,6 +8,10 @@
# 4.4.4 (TODO: UPDATE THE DATE ON MERGE DAY)
## 🐛 Bug fixes
- [#300](https://github.com/unity-atoms/unity-atoms/pull/300) Fixed Serialization on AtomCollections.
## 📝 Documentation
- A "Smooth Workflow" section has been added under the CONTRIBUTING.md to explain how one can easily start contributing to Atoms whilst working from inside Unity. This was an issue as the atoms repository is not naturally compatible with Unity. ([@Casey-Hofland](https://github.com/Casey-Hofland))

View File

@ -53,6 +53,11 @@ namespace UnityAtoms.BaseAtoms
void OnDisable()
{
if (Value == null) return;
//Calling OnAfterDeserialize again here, as Collection may use StringConstant or StringVariable as key, and Unity doesnt ensures execution order in Scriptable Objects
// As such is possible that the Collection is called before its keys are ready to be used.
// On OnEnable, all atoms are supposed to already have been initialized, and calling OnAfterDeserialize, will fix any issue with not ready keys
Value.OnAfterDeserialize();
Value.Added -= PropogateAdded;
Value.Removed -= PropogateRemoved;