I’ve looked around, and I can’t seem to find an answer as to whether there is a performance difference between these.
I know that SetComponent/SetComponentData will error out if the Component doesn’t already exist, while AddComponent/AddComponentData will overwrite any existing data for the component (without erroring).
Based on this, I would favor always using AddComponent, but is there any performance advantage to using SetComponent if you’re sure that the Component exists?
As I know, AddComponent will change of the entity’s archetype and cause memory chunk change. The components data on that entity may move to another memory chunk that meets the same archtype.
SetComponentData will not cause memory change~