Search Unity

Duplicate add of tag components is allowed, but what about regular ones?

Discussion in 'Entity Component System' started by e199, May 31, 2019.

  1. e199

    e199

    Joined:
    Mar 24, 2015
    Posts:
    101
    Hi

    Why we are allowed to add tag components twice without an error?
    Why we are not allowed to do the same with regular components?

    upload_2019-5-31_14-48-13.png
     
    Last edited: May 31, 2019
  2. Xerioz

    Xerioz

    Joined:
    Aug 13, 2013
    Posts:
    104
    If you set a tag twice, the result will be the same. Therefor duplicate tag components don't change anything.
    If you set a regular component twice, which values would it use? New one or old one? I think there's more work involved.

    If duplicate component data error was removed, then what would be the difference between AddComponentData and SetComponentData ? Personally, the duplicate component error helped me optimize code in several cases, where I was mindlessly adding components multiple times.