diff --git a/CHANGELOG.md b/CHANGELOG.md index 07b5f96..7845d98 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this package will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [0.6.1] - 2024-11-01 + +**Fix**: +- Fixed an issue that would crash the execution when calling *Remove()* & *RemoveOrigin* from *ObservableResolverDictionary* + ## [0.6.0] - 2023-08-05 - Improved the *ObservableResolverList* and *ObservableResolverDictionary* data types to properly resolve lists and dictionaries with different data types from the original collection. diff --git a/Runtime/ObservableDictionary.cs b/Runtime/ObservableDictionary.cs index 94ce25b..9168028 100644 --- a/Runtime/ObservableDictionary.cs +++ b/Runtime/ObservableDictionary.cs @@ -453,7 +453,9 @@ public override void Add(TKey key, TValue value) /// public override bool Remove(TKey key) { - var pair = _toOrignResolver(key, Dictionary[key]); + if(!Dictionary.TryGetValue(key, out var value)) return false; + + var pair = _toOrignResolver(key, value); _dictionary.Remove(pair.Key); @@ -479,7 +481,9 @@ public void AddOrigin(TKeyOrigin key, TValueOrigin value) /// public bool RemoveOrigin(TKeyOrigin key) { - var convertPair = _fromOrignResolver(new KeyValuePair(key, OriginDictionary[key])); + if (!_dictionary.TryGetValue(key, out var value)) return false; + + var convertPair = _fromOrignResolver(new KeyValuePair(key, value)); _dictionary.Remove(key); return base.Remove(convertPair.Key); diff --git a/package.json b/package.json index af7dfed..a5dae5c 100644 --- a/package.json +++ b/package.json @@ -2,8 +2,8 @@ "name": "com.gamelovers.dataextensions", "displayName": "Unity Data Type Extensions", "author": "Miguel Tomas", - "version": "0.6.0", - "unity": "2022.4", + "version": "0.6.1", + "unity": "2022.3", "license": "MIT", "description": "This package extends various sets of data types to be used in any type of data containers or persistent serializable data", "type": "library",