type {t} is a ISharedComponentData and has managed references, you must implement IEquatable<T>

I received this error after updating ECS. What are the implications? Is it just an interface I have to implement or am I doing something wrong with my ISharedComponentData? How do I go about implementing this interface?

Thanks. Happy 2020!

SCD works by trying to make different instance of SCD value (just new it the line before, etc.) sent to EntityManager at different place in code works like they are the same instance, so chunks could truly share it. It needs to hash to see if a new SCD coming later is the same thing, therefore associate the same SCD index to chunk instead of new index. (and increase ref count for that index)

This maybe easy if inside SCD is just one or two integers, even though normally you can’t == 2 custom structs together in C# the lib has some shortcuts like directly compare memory/hash of memory, which wouldn’t work 100% if you have pointers because you are then comparing just address number instead of actual value inside. Unity would check if you really have no ref type in SCD before doing this. When you do have ref type Unity can’t do that and try to call Equals you implemented instead. Implication is that you control what would be considered the same or different SCD in your Equals.

struct SCD : ISharedComponentData, IEquatable { int value; Material m; } then Equals has only this.value == other.value , m ignored.

Didn’t try but I think this is what would happen : If you em.SetSharedComponentData(eq1, new SCD { value = 10; m = mat1; } ) and then em.SetSharedComponentData(eq2, new SCD { value = 10; m = mat2; } ), the chunks returned by eq2 will get the same SCD index as chunks returned by eq1, and when you try to get SCD value for any entities in eq2 you would get mat1 inside as SCD with mat2 never passed the hash test as a new value. If you switch order then mat1 will not ever be added to SCD list the same way, since mat2 came first then when mat1 ones came the hash didn’t detect it as a new SCD value.

2 Likes