-
Changed implementation of
EntityStore.CloneEntity()
Old: Used JSON serialization as fallback if source entity has one or more non-blittable component types.
E.g. a struct component containing fields with reference types like aarray
,List<>
orDictionary<,>
.New: Non-blittable components are now cloned using a static
CopyValue()
method with must part of component type.
E.g.public struct MyComponent : IComponent { public int[] array; static void CopyValue(in MyComponent source, ref MyComponent target, in CopyContext context) { target.array = source.array?.ToArray(); } }
In case
CopyValue()
is missing an exception is thrown including the required method signature in the exception message.
Info: Removing JSON serialization from cloning has additional advantages.- Much faster as JSON serialization/deserialization is expensive.
- No precision loss when using floating point types.