#Bugfix for Entity Remapping of IDictionary<K,V>

1 messages · Page 1 of 1 (latest)

lusty sage
#

I noticed that the managed Entity Remapper supports basically every datatype except Dictionaries. This is because Unity.Properties treats Dictionaries as Read-Only by default (in order to avoid modifying keys).

However, it's safe to modify values in a dictionary during traversal, so it's safe to remap Entity references that are a part of the values.

I've added support for Dictionaries to the Entity Remapper in this PR for our fork of com.unity.entities: https://github.com/Pontoco/com.unity.entities/pull/1

I'll go ahead and file a bug for this. As is, using Entity references in a Dictionary results in corrupted entity referenced, which is quite a bit of a footgun!

GitHub

Adds support for Dictionary<K,V> for entity remapping when copying / loading / instantiating entities.
By default, Unity.Properties treats Dictionaries as readonly when traversing them. This ...

lusty sage
#

Hm. This affects Entity Patching too. Patching works with all entity references, except those that are values of Dictionaries. Same problem: KeyValuePairPropertyBag doesn't create a setter for the value.

That results in corrupted entity references after baking 😬